fork download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. template<class...>struct voider{using type=void;};
  5. template<class...Ts>using void_t=typename voider<Ts...>::type;
  6.  
  7. template<class T>
  8. void f(std::conditional_t< std::is_same<T,double>::value, T, void >)
  9. {
  10. std::cout << "hello world!\n";
  11. }
  12.  
  13. int main() {
  14. f<int>();
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:14:12: error: no matching function for call to 'f()'
     f<int>();
            ^
prog.cpp:14:12: note: candidate is:
prog.cpp:8:6: note: template<class T> void f(std::conditional_t<std::is_same<T, double>::value, T, void>)
 void f(std::conditional_t< std::is_same<T,double>::value, T, void >)
      ^
prog.cpp:8:6: note:   template argument deduction/substitution failed:
prog.cpp: In substitution of 'template<class T> void f(std::conditional_t<std::is_same<T, double>::value, T, void>) [with T = int]':
prog.cpp:14:12:   required from here
prog.cpp:8:6: error: invalid parameter type 'std::conditional_t<false, int, void> {aka void}'
stdout
Standard output is empty