fork download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std::placeholders;
  4.  
  5. struct X
  6. {
  7. int i;
  8.  
  9. int value() const { return i; }
  10. };
  11.  
  12. int main()
  13. {
  14. std::vector<X> xs;
  15. X a = {97};
  16. X b = {42};
  17. xs.push_back(a);
  18. xs.push_back(b);
  19. auto it = std::find_if(xs.begin(), xs.end(), std::bind(std::equal_to<int>(), 42, std::bind(&X::value, _1)));
  20. std::cout << (it - xs.begin()) << '\n';
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:14:2: error: 'vector' is not a member of 'std'
prog.cpp:14:15: error: expected primary-expression before '>' token
prog.cpp:14:17: error: 'xs' was not declared in this scope
prog.cpp:19:12: error: 'find_if' is not a member of 'std'
prog.cpp:19:108: error: unable to deduce 'auto' from '<expression error>'
stdout
Standard output is empty