fork(1) download
  1. #include <iostream>
  2.  
  3. #include <string>
  4. #include <vector>
  5.  
  6. namespace details
  7. {
  8. template <typename T>
  9. struct f_caller
  10. {
  11. static void f() { std::cout << "generic" << std::endl; }
  12. };
  13.  
  14. template<>
  15. struct f_caller<std::string>
  16. {
  17. static void f() { std::cout << "string" << std::endl; }
  18. };
  19.  
  20. template<typename T>
  21. struct f_caller<std::vector<T>>
  22. {
  23. static void f() { std::cout << "vector" << std::endl; }
  24. };
  25. }
  26.  
  27. template<typename T>
  28. void f()
  29. {
  30. details::f_caller<T>::f();
  31. }
  32.  
  33. int main()
  34. {
  35. f<double>();
  36. f<std::string>();
  37. f<std::vector<int>>();
  38.  
  39. return 0;
  40. }
  41.  
  42.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
generic
string
vector