fork(2) download
  1. typedef bool(*func)(int);
  2.  
  3. //template<typename T = int>
  4. //class TC1{
  5. // public:
  6. // static bool test_func(T t){
  7. // return true;
  8. // }
  9. //};
  10.  
  11. template<typename T=int>
  12. bool test_func(T){
  13. return true;
  14. }
  15.  
  16. template< func f = &test_func>
  17. class TC2{
  18. public:
  19. TC2(){
  20. //uncomment the line below ,compile will pass
  21. //test_func(3);
  22. f(3);
  23. }
  24. };
  25.  
  26. template<typename T = char>
  27. class TC3{
  28. public:
  29. TC2<> mc;
  30. TC3() = default;
  31. };
  32.  
  33. int main(){
  34. TC3<> tc3;
  35. //uncomment the line below ,compile will pass
  36. //TC2<> mc;
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/7NWKv7/ccwlqIxB.o: In function `main':
prog.cpp:(.text.startup+0xa): undefined reference to `bool test_func<int>(int)'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty