fork download
  1. #include <set>
  2. #include <iostream>
  3.  
  4. namespace test {
  5. struct test {
  6. int A;
  7. int B;
  8. };
  9.  
  10. bool operator< (test const& lhs, test const& rhs) {
  11. return lhs.A < rhs.A;
  12. }
  13.  
  14. struct test_B { double B; };
  15.  
  16. bool operator< (test const& lhs, test_B const& rhs) {
  17. return lhs.B < rhs.B;
  18. }
  19.  
  20. bool operator< (test_B const& lhs, test const& rhs) {
  21. return lhs.B < rhs.B;
  22. }
  23. }
  24.  
  25. int main() {
  26.  
  27. std::set<test::test, std::less<void>> example {
  28. {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}
  29. };
  30.  
  31. std::cout << example.lower_bound<test::test_B>({3.5})->B;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
4