fork download
  1. #include<type_traits>
  2.  
  3. template<class C, class T = int>
  4. using EnableIf = typename std::enable_if<C::value, T>::type;
  5.  
  6. struct value1 { static const bool value = true; };
  7. struct value2 { static const bool value = false; };
  8.  
  9. template<class T, EnableIf<std::is_integral<T>>...> // doesn't work
  10. //template<class T, EnableIf<std::is_integral<T>> = 0> // works!
  11. void fun(T){ };
  12. template<class T, EnableIf<std::is_floating_point<T>>...> // doesn't work
  13. //template<class T, EnableIf<std::is_floating_point<T>> = 0 > // works
  14. void fun(T) { };
  15.  
  16. int main() {
  17. fun(1);
  18. }
  19.  
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty