fork(8) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T>
  5. struct A {
  6. int val = 0;
  7.  
  8. template<typename Integer, typename std::enable_if<T::value && std::is_convertible<Integer,int>::value>::type...>
  9. A(Integer n) : val(n) {};
  10.  
  11. A(...) {}
  12. /* ... */
  13. };
  14.  
  15. struct YES { constexpr static bool value = true; };
  16. struct NO { constexpr static bool value = false; };
  17.  
  18. int main() {
  19. A<YES> y(10);
  20. A<NO> n;
  21. std::cout << "YES: " << y.val << std::endl
  22. << "NO: " << n.val << std::endl;
  23. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
YES: 10
NO:  0