fork(1) download
  1. #include <vector>
  2. #include <unordered_set>
  3. #include <functional>
  4.  
  5. struct Point
  6. {
  7. float x;
  8. float y;
  9. Point() : x(0), y(0) {}
  10. };
  11.  
  12. int main()
  13. {
  14. auto hash=[](const Point& pt){
  15. return (size_t)(pt.x*100 + pt.y);
  16. };
  17. auto hashFunc=[&hash](){
  18. return std::function<size_t(const Point&)> (hash);
  19. };
  20. auto equal=[](const Point& pt1, const Point& pt2){
  21. return ((pt1.x == pt2.x) && (pt1.y == pt2.y));
  22. };
  23. auto equalFunc=[&equal](){
  24. return std::function<size_t(const Point&,const Point&)> (equal);
  25. };
  26. using PointHash=std::unordered_set<Point,decltype(hashFunc),decltype(equalFunc)>;
  27. //equalKey()(Point(),Point());//ok
  28. PointHash Test(10,hashFunc,equalFunc);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty