Metaprogramming with std::is_same

后端 未结 2 1387
广开言路
广开言路 2021-02-07 20:07

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:34

    Yes, with template specialization :

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

提交回复
热议问题