Nested Template Specialization

后端 未结 7 2050
南旧
南旧 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 03:09

    You can't do that. I've tried many variations. This, however, compiles in GCC 4.1:

    template<int a> struct Foo
    {
        template<int b> struct Bar;
        template<1> struct Bar;
    };
    

    Edit (after reviewing the standard): If a is given, however, you can do this:

    template <> template <> Foo<1> Bar<1>;
    

    But not if Foo is not first specialized.

    0 讨论(0)
提交回复
热议问题