Skip to content

Instantly share code, notes, and snippets.

@stevedoyle
stevedoyle / cpu_freq
Last active February 12, 2024 01:01
Get CPU frequency (Linux platforms - /proc/cpuinfo)
#include <iostream>
#include <fstream>
#include <string>
#include <stdint.h>
#include <pcre.h>
using namespace std;
uint32_t cpufreq()
{
@stevedoyle
stevedoyle / gist:1287180
Created October 14, 2011 13:55
Calling a member function on every item in a container using for_each and mem_fun
for_each(foos.begin(), foos.end(), mem_fun(&Foo::doStuff));
// Example ...
class Foo
{
public:
Foo();
void doStuff();
@stevedoyle
stevedoyle / gist:1287095
Created October 14, 2011 13:27
Functor for deleting objects in a container using for_each
template <class T>
class DeleteObj
{
public:
void operator()(T*obj) { delete obj; }
};
// Sample usage ...
class Foo