fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. class foo {
  7. public:
  8. foo(char ch, int flag = int()) : flag(flag), ch(ch) {}
  9. int flag;
  10. char ch;
  11. inline bool operator ==(const char & rhs) { return ch == rhs; }
  12. };
  13.  
  14. int main(void) {
  15. vector<foo> vec;
  16. vec.push_back(('a', 1));
  17. vec.push_back(('b', 2));
  18. vec.push_back(('c', 3));
  19. vector<foo>::iterator it = std::find(vec.begin(), vec.end(), 'b');
  20. if (it != vec.end()) {
  21. cout << "found" << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
found