fork(1) download
  1. #include<iostream>
  2. #include<set>
  3. #include<vector>
  4. #include<functional>
  5.  
  6. int32_t main(void){
  7.  
  8. std::vector < std::pair<int,int> > v = { {1,2} , {1,2} };
  9.  
  10. std::function<bool(int, int)> func = [&v](int i, int j) { return v[i] > v[j]; };
  11.  
  12. std::set<int, decltype(func)> index_set(func);
  13.  
  14. index_set.insert(0);
  15. index_set.insert(1);
  16.  
  17. std::cout<< "Why is set size equal to " << index_set.size() << ". Keys ({0,1}) inserted are not equivalent.\n";
  18. // Why is size still 1?
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Why is set size equal to 1. Keys ({0,1}) inserted are not equivalent.