fork download
  1. #include <vector>
  2. #include <memory>
  3. #include <algorithm>
  4. #include <functional>
  5. #include <iostream>
  6.  
  7. int main()
  8. {
  9. typedef std::unique_ptr<double> STDUPD;
  10.  
  11. std::vector<STDUPD> vIn;
  12. vIn.push_back(STDUPD(new double(5)));
  13. vIn.push_back(STDUPD(new double(2)));
  14. vIn.push_back(STDUPD(new double(6)));
  15.  
  16. using namespace std::placeholders;
  17. std::sort(
  18. vIn.begin(),
  19. vIn.end(),
  20. std::bind(
  21. std::less<double>(),
  22. std::bind(&STDUPD::operator*, _1),
  23. std::bind(&STDUPD::operator*, _2)
  24. )
  25. );
  26.  
  27. std::vector<STDUPD>::const_iterator it = vIn.begin(), end = vIn.end();
  28. for ( ; it != end; ++it)
  29. std::cout << ',' << **it;
  30. }
Success #stdin #stdout 0s 3068KB
stdin
Standard input is empty
stdout
,2,5,6