fork download
  1. #include <vector>
  2. #include <set>
  3.  
  4. #include <algorithm>
  5.  
  6. struct point // A simple custom point structure
  7. {
  8. int x, y;
  9. };
  10.  
  11. int main()
  12. {
  13. // Lambda created by the wizard
  14. // --------------------------------------------------
  15.  
  16. auto point_lambda = [] (const point &left, const point &right) -> bool
  17. {
  18. if (left.x == right.x)
  19. return (left.y < right.y);
  20. else
  21. return (left.x < right.x);
  22. };
  23.  
  24. // --------------------------------------------------
  25.  
  26. std::vector<point> v;
  27. std::sort(v.begin(), v.end(), point_lambda); //Compiles happily with point structures
  28.  
  29. std::set<point, decltype(point_lambda)> s(point_lambda);
  30. s.find(point()); //Compiles happily with point structures
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty