Nested Template Specialization

后端 未结 7 2061
南旧
南旧 2020-12-14 02:12

Having a brain fart... Is it possible to make something like this work?

template struct Foo
{
    template struct Bar;
};

template         


        
7条回答
  •  再見小時候
    2020-12-14 02:55

    As the previous posters explained, this is not possible. You can however move the nested template into a non-template base class:

    struct FooBase
    {
        template struct Bar;
    }
    template struct Foo : public FooBase
    {
    };
    
    struct FooBase::Bar<1> // specializing Bar
    {
    };
    

提交回复
热议问题