fork download
  1. #include <algorithm>
  2. #include <functional>
  3. #include <iostream>
  4. #include <iterator>
  5.  
  6. using namespace std;
  7.  
  8. #define SIZE 42
  9.  
  10. class Foo{
  11. bool checked;
  12. public:
  13. Foo() : checked(false) {}
  14. void setChecked() { checked = true; }
  15. bool isChecked() const { return checked; }
  16. };
  17.  
  18. int main() {
  19. Foo foos[SIZE] = {};
  20.  
  21. foos[13].setChecked();
  22.  
  23. cout << distance(foos, find_if(foos, foos + SIZE, mem_fun_ref(&Foo::isChecked))) << endl;
  24. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
13