Skip to content

Instantly share code, notes, and snippets.

@raek
Created December 13, 2009 18:09
Show Gist options
  • Save raek/255540 to your computer and use it in GitHub Desktop.
Save raek/255540 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
class print_on: public binary_function<ostream&, int, void>
{
public:
void operator ()(ostream& os, int value) const
{
os << value << endl;
}
};
int main(int args, char* argv[])
{
vector<int> ints;
for (int i = 0; i < 10; i++)
ints.push_back(i);
for_each(ints.begin(), ints.end(), bind1st(print_on(), cout));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment