fork download
  1. struct MyObj {
  2. int getID() {return 2;}
  3. };
  4.  
  5. struct MyObj2 {
  6. int getID() {return 3;}
  7. };
  8.  
  9. #include <vector>
  10. #include <algorithm>
  11. #include <iostream>
  12.  
  13. int main() {
  14. std::vector<MyObj> v;
  15. std::vector<MyObj2> _z;
  16.  
  17. for (unsigned i=0; i < _z.size(); i++)
  18. {
  19. MyObj2 _g = _z.at(i);
  20.  
  21. auto iter = std::find_if(v.begin(), v.end(), [&](MyObj o)
  22. {
  23. if (o.getID() == _g.getID())
  24. {
  25. std::cout << "we have a match" << std::endl;
  26. return true;
  27. }
  28. else
  29. {
  30. std::cout << "we DO NOT have a match" << std::endl;
  31. return false;
  32. }
  33. });
  34. }
  35.  
  36. }
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty