Nested Template Specialization

后端 未结 7 2088
南旧
南旧 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 struct Foo
    {
        template 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.

提交回复
热议问题