fork(1) download
  1. #include <type_traits>
  2.  
  3. template <typename T>
  4. std::enable_if_t< std::is_integral<T>::value, // test is true for T=int
  5. void> foo( T& ) {}
  6.  
  7. template <typename T>
  8. std::enable_if_t< std::is_pointer<T>::value, // test is false for T=int
  9. void> foo( T& ) {}
  10.  
  11. void bar( )
  12. {
  13. int i;
  14. foo( i ); // calls foo( int& ) (obviously), compiles fine
  15. }
  16. template void foo( int& ); // explicit instantiation, throws compiler error
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty