Skip to content

Instantly share code, notes, and snippets.

@bradtgmurray
Created August 11, 2009 13:55
Show Gist options
  • Save bradtgmurray/165836 to your computer and use it in GitHub Desktop.
Save bradtgmurray/165836 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <functional>
#include <vector>
class A
{
int value;
public:
void Add(int num)
{
value += num;
}
};
std::vector<A> numbers;
// Add 2 to each object in the vector.
// Ohhhh yeahhhh
// Errr, should this be bind1st or bind2nd?
std::for_each(numbers.begin(), numbers.end(),
std::bind1st(std::mem_fun_ref(&A::Add), 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment