fork download
  1. #include <iostream>
  2.  
  3.  
  4. template<typename>
  5. class type {
  6.  
  7. void _f() {}
  8.  
  9. template<typename T>
  10. friend void f(type<T>);
  11. };
  12.  
  13. template<typename T>
  14. void f(type<T> t) {
  15. t._f();
  16. std::cout << "1" << std::endl;
  17. }
  18.  
  19. template<>
  20. void f(type<char> t) {
  21. t._f();
  22. std::cout << "2" << std::endl;
  23. }
  24.  
  25.  
  26. int main() {
  27. type<int> t1;
  28. type<char> t2;
  29. f(t1);
  30. f(t2);
  31. }
  32.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
1
2