fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class T, typename comp>
  5. struct klasa {
  6. klasa(const T &a, const T &b, comp C = greater<T>())
  7. {
  8. cout << C(a, b) << endl;
  9. }
  10. };
  11.  
  12. struct MyCompare
  13. {
  14. bool operator()(const int& a, const int& b) { return true; }
  15. };
  16.  
  17. bool fPtr(const int& a, const int& b) { return false; }
  18.  
  19. int main()
  20. {
  21. klasa<int, greater<int>> a(1, 2);
  22. klasa<int, MyCompare> b(5, 2, MyCompare());
  23.  
  24. auto lessThan = [](const int& a, const int& b) { return a < b; };
  25. klasa<int, decltype(lessThan)> c(1, 5, lessThan);
  26.  
  27. klasa<int, decltype(fPtr)> d(0, 0, fPtr);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
0
1
1
0