Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <type_traits>
  2. #include <iostream>
  3. #include <string>
  4.  
  5.  
  6.  
  7. template<class T, class Enable = void>
  8. struct A {
  9. static void f(){
  10. std::cout << "Global" << std::endl;
  11. }
  12. };
  13. template<class T>
  14. struct A<T, void> {
  15. static void f(){
  16. std::cout << "Specialization void" << std::endl;
  17. }
  18. };
  19. template<class T>
  20. struct A<T, int> {
  21. static void f(){
  22. std::cout << "Specialization int" << std::endl;
  23. }
  24. };
  25. template<typename T>
  26. void f(T val){
  27. A<T>::f();
  28. }
  29.  
  30. int main()
  31. {
  32. f(0);
  33. f('ch');
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement