fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct example {
  5. int compare_element, b, c;
  6. };
  7.  
  8. struct cmp {
  9. bool operator() (const example& a, const example& b) const {
  10. return a.compare_element < b.compare_element;
  11. }
  12. };
  13.  
  14. int main() {
  15.  
  16. set<example, cmp> se;
  17. se.insert({1, 2, 3});
  18. se.insert({1, 5, 6});
  19. cout<<se.size()<<"\n";
  20.  
  21. for(example e: se)
  22. {
  23. cout<<"{ "<<e.compare_element<<" "<<e.b<<" "<<e.c<<"}\n";
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 4856KB
stdin
Standard input is empty
stdout
1
{ 1 2 3}