fork(1) download
  1. #include <type_traits>
  2.  
  3. template<typename Integer,
  4. std::enable_if_t<std::is_integral<Integer>::value>* = 0>
  5. void foo(Integer) {}
  6.  
  7. template<typename Floating,
  8. std::enable_if_t<std::is_floating_point<Floating>::value>* = 0>
  9. void foo(Floating) {}
  10.  
  11. int main()
  12. {
  13. foo(3);
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:10: error: no matching function for call to ‘foo(int)’
     foo(3);
          ^
prog.cpp:5:6: note: candidate: template<class Integer, std::enable_if_t<std::is_integral<_Tp>::value>* <anonymous> > void foo(Integer)
 void foo(Integer) {}
      ^~~
prog.cpp:5:6: note:   template argument deduction/substitution failed:
prog.cpp:4:64: error: could not convert template argument ‘0’ to ‘std::enable_if_t<true, void>* {aka void*}’
          std::enable_if_t<std::is_integral<Integer>::value>* = 0>
                                                                ^
prog.cpp:9:6: note: candidate: template<class Floating, std::enable_if_t<std::is_floating_point<_Tp>::value>* <anonymous> > void foo(Floating)
 void foo(Floating) {}
      ^~~
prog.cpp:9:6: note:   template argument deduction/substitution failed:
prog.cpp:8:71: note: invalid template non-type parameter
          std::enable_if_t<std::is_floating_point<Floating>::value>* = 0>
                                                                       ^
stdout
Standard output is empty