Partially specializing member-function implementations

前端 未结 4 692
温柔的废话
温柔的废话 2021-01-20 04:58

I\'m currently refactoring some code the explicitly specializes a member function of a class template with two template parameters.

template 

        
4条回答
  •  一向
    一向 (楼主)
    2021-01-20 05:32

    I do not think that what you want is that easily possible. What about something like this:

    template 
    class FooBase
    {
        void bar();
    };
    
    template 
    void FooBase::bar()
    { /* Generic stuff */ }
    
    template 
    class Foo
        : public FooBase 
    { };
    
    template 
    class Foo
        : public FooBase 
    {
        void bar ();
    };
    
    template 
    void Foo::bar()
    { /* Some special function */ }
    

提交回复
热议问题