fork(3) download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. std::enable_if_t<std::is_same<int, T>::value, void> foo() {
  5. std::cout << "foo int\n";
  6. }
  7.  
  8. template<typename T>
  9. std::enable_if_t<std::is_same<float, T>::value, void> foo() {
  10. std::cout << "foo float\n";
  11. }
  12.  
  13. int main() {
  14. foo<int>();
  15. foo<float>();
  16. foo<char*>();
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:14: error: no matching function for call to 'foo()'
   foo<char*>();
              ^
prog.cpp:16:14: note: candidates are:
prog.cpp:4:54: note: template<class T> std::enable_if_t<std::is_same<int, T>::value, void> foo()
  std::enable_if_t<std::is_same<int, T>::value, void> foo() {
                                                      ^
prog.cpp:4:54: note:   template argument deduction/substitution failed:
prog.cpp:9:56: note: template<class T> std::enable_if_t<std::is_same<float, T>::value, void> foo()
  std::enable_if_t<std::is_same<float, T>::value, void> foo() {
                                                        ^
prog.cpp:9:56: note:   template argument deduction/substitution failed:
stdout
Standard output is empty