Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <type_traits>
- #include <iostream>
- #include <string>
- template<class T, class Enable = void>
- struct A {
- static void f(){
- std::cout << "Global" << std::endl;
- }
- };
- template<class T>
- struct A<T, void> {
- static void f(){
- std::cout << "Specialization void" << std::endl;
- }
- };
- template<class T>
- struct A<T, int> {
- static void f(){
- std::cout << "Specialization int" << std::endl;
- }
- };
- template<typename T>
- void f(T val){
- A<T>::f();
- }
- int main()
- {
- f(0);
- f('ch');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement