fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T>
  5. struct A {
  6. int val = 0;
  7.  
  8. template<size_t N,
  9. typename U = T,
  10. typename = std::enable_if_t<sizeof(U)>
  11. >
  12. A(int (&ar)[N]) {};
  13.  
  14. A(){}
  15. };
  16.  
  17. struct YES {};
  18. struct NO;
  19.  
  20. int main() {
  21. int a[10];
  22. A<YES> y(a);
  23. A<NO> n;
  24. std::cout << "YES: " << y.val << std::endl
  25. << "NO: " << n.val << std::endl;
  26. }
Success #stdin #stdout 0s 5220KB
stdin
Standard input is empty
stdout
YES: 0
NO:  0