Metaprogramming with std::is_same

后端 未结 2 1157
無奈伤痛
無奈伤痛 2021-02-07 19:55

Is it possible to do something like the following that compiles without template specialization?

template  
class A {
public:
  #if std::is_same&l         


        
2条回答
  •  抹茶落季
    2021-02-07 20:32

    Yes, with template specialization :

    template  
    class A;
    
    template <> 
    class A
    {
        void had_int(){}
    };
    
    template <> 
    class A
    {
        void had_char(){}
    };
    

提交回复
热议问题