Identifying primitive types in templates

后端 未结 8 848
南旧
南旧 2020-11-27 17:40

I am looking for a way to identify primitives types in a template class definition.

I mean, having this class :

template
class A{
void         


        
8条回答
  •  借酒劲吻你
    2020-11-27 18:27

    Yet another similar examples:

    #include  
    #include 
    
    template
    struct foo_impl
    {
        void do_work()
        {
            std::cout << "0" << std::endl;
        }
    };
    template
    struct foo_impl
    {
        void do_work()
        {
            std::cout << "1" << std::endl;
        }
    };
    
    template
    struct foo
    {
        void do_work()
        {
            foo_impl::value>().do_work();
        }
    };
    
    
    int main()
    {
        foo a; a.do_work();
        foo b; b.do_work();
    }
    

提交回复
热议问题