Skip to content

Instantly share code, notes, and snippets.

@bradtgmurray
Created September 22, 2009 16:00
Show Gist options
  • Save bradtgmurray/191178 to your computer and use it in GitHub Desktop.
Save bradtgmurray/191178 to your computer and use it in GitHub Desktop.
class WellBehavedFunctor : public unary_functor<int, bool>
{
public:
bool operator()(int i) { return i < 3; }
}
std::vector<int> numbers;
// Prints the number of numbers in the numbers vector that are 3 or greater.
std::cout << std::count_if(numbers.begin(), numbers.end(), std::not1(WellBehavedFunctor()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment