fork download
  1. #include <set>
  2. #include <iostream>
  3.  
  4. struct A {
  5. int i;
  6. A() : i(0) {}
  7. bool operator()(int a, int b)
  8. {
  9. ++i;
  10. return a < b;
  11. }
  12. };
  13.  
  14. int main()
  15. {
  16. A a;
  17. std::set<int, A&> s1( {1, 2, 3}, a);
  18. std::set<int, A&> s2( {4, 5, 6}, a);
  19. std::cout << a.i;
  20. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
8