fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <set>
  4. #include <functional>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, const char * argv[])
  10. {
  11. int a[10] = { 8,2,4,9,1,3,7,5,6,0 };
  12.  
  13. set<int*,function<bool(int*,int*)>> s([](int*a,int*b){ return *a < *b; });
  14. for(int i = 0; i < 10; ++i)
  15. s.insert(&a[i]);
  16. for(auto p: s) cout << *p << endl;
  17.  
  18. }
  19.  
Success #stdin #stdout 0s 4428KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9