fork download
  1. #include <functional>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iostream>
  5.  
  6. bool pred(const std::string& s)
  7. {
  8. return s.size() % 2;
  9. }
  10.  
  11. int main()
  12. {
  13. std::string data[] = { "hello", "world!" };
  14.  
  15. std::cout << std::count_if(data, data+2,
  16. pred) << std::endl;
  17.  
  18. std::cout << std::count_if(data, data+2,
  19. std::ptr_fun(pred) ) << std::endl;
  20.  
  21. std::cout << std::count_if(data, data+2,
  22. std::not1(std::ptr_fun(pred))) << std::endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
1
1
1