fork download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5.  
  6. template <int N>
  7. struct S
  8. {
  9. template <typename T>
  10. typename enable_if<(sizeof(T)>0) && N==1, int>::type
  11. f(T t) { return 1; }
  12.  
  13. template <typename T>
  14. typename enable_if<(sizeof(T)>0) && N!=1, int>::type
  15. f(T t) { return 0; }
  16. };
  17.  
  18. int main()
  19. {
  20. S<1> s1;
  21. S<2> s2;
  22. cout << s1.f(99) << " " << s2.f(99) << endl;
  23. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
1 0