fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <set>
  6.  
  7. class MyClass
  8. {
  9. public:
  10. typedef unsigned int ContentType;
  11.  
  12. struct MyCompare
  13. {
  14. const MyClass& obj;
  15. MyCompare( const MyClass& mc ) : obj(mc) { }
  16.  
  17. bool operator ()(const ContentType& lhs,
  18. const ContentType& rhs) const
  19. {
  20. // return something meaningful
  21. return obj.otherMember[lhs] < obj.otherMember[rhs];
  22. }
  23. };
  24.  
  25. MyClass() : mySet(*this)
  26. {
  27. }
  28.  
  29. private:
  30. std::set<ContentType, MyCompare> mySet;
  31. std::vector<int> otherMember;
  32. };
  33.  
  34. int main()
  35. {
  36. MyClass mc;
  37. return 0;
  38. }
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty