fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T>
  5. void do_stuff(std::enable_if_t<std::is_integral<T>::value, T> &t) {}
  6.  
  7. template <typename T>
  8. void do_stuff(std::enable_if_t<std::is_class<T>::value, T> &t) {}
  9.  
  10. int main() {
  11. // your code goes here
  12. int i = 1;
  13. do_stuff(i);
  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()':
prog.cpp:13:12: error: no matching function for call to 'do_stuff(int&)'
  do_stuff(i);
            ^
prog.cpp:5:6: note: candidate: template<class T> void do_stuff(std::enable_if_t<std::is_integral<_Tp>::value, T>&)
 void do_stuff(std::enable_if_t<std::is_integral<T>::value, T> &t) {}
      ^
prog.cpp:5:6: note:   template argument deduction/substitution failed:
prog.cpp:13:12: note:   couldn't deduce template parameter 'T'
  do_stuff(i);
            ^
prog.cpp:8:6: note: candidate: template<class T> void do_stuff(std::enable_if_t<std::is_class<T>::value, T>&)
 void do_stuff(std::enable_if_t<std::is_class<T>::value, T> &t) {}
      ^
prog.cpp:8:6: note:   template argument deduction/substitution failed:
prog.cpp:13:12: note:   couldn't deduce template parameter 'T'
  do_stuff(i);
            ^
stdout
Standard output is empty