fork download
  1. #include <type_traits>
  2.  
  3. template <typename T, typename std::enable_if<std::is_floating_point<T>{} || std::is_integral<T>{}, T>::type * = nullptr>
  4. void fn(T a, T b)
  5. {
  6. }
  7.  
  8. struct Foo {};
  9.  
  10. int main(int, const char **)
  11. {
  12. //fn<Foo>(Foo{}, Foo{});
  13. fn<Foo, void>(Foo{}, Foo{});
  14. return 0;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, const char**)’:
prog.cpp:13:28: error: no matching function for call to ‘fn(Foo, Foo)’
  fn<Foo, void>(Foo{}, Foo{});
                            ^
prog.cpp:4:6: note: candidate: template<class T, typename std::enable_if<(std::is_floating_point<_Tp>{} || std::is_integral<_Tp>{}), T>::type* <anonymous> > void fn(T, T)
 void fn(T a, T b)
      ^~
prog.cpp:4:6: note:   template argument deduction/substitution failed:
stdout
Standard output is empty