小编Rad*_*ich的帖子

具有依赖于包含类的参数包的非类型参数包的可变参数模板类的静态成员的类外定义

对于以下代码:

template<class... Parameter> struct Outer
{
    template<Parameter... Value> struct Inner
    {
        static bool Member;
    };
};

template<class... Parameter>
template<Parameter... Value>
bool Outer<Parameter...>::Inner<Value...>::Member = true;

int main()
{
    Outer<int>::Inner<0>::Member = false;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

GCC 7.3.0 报告:

error: expansion pattern 'Value' contains no argument packs
 bool Outer<Parameter...>::Inner<Value...>::Member = true;
Run Code Online (Sandbox Code Playgroud)

和 Visual Studio 16.7.2,类似地,大约相同的Value参数包:

error C3546: '...': there are no parameter packs available to expand
Run Code Online (Sandbox Code Playgroud)

如果在同一代码Parameter中不是参数包,或者Value不依赖于Parameter.

为什么会发生这些错误?这种情况是否需要一些特殊的语法?

我知道,因为c++17它可以通过使用inline关键字定义类中的成员来解决。但是c++11,如果可能的话,我希望我的代码与 …

c++ static templates non-type variadic-templates

5
推荐指数
0
解决办法
157
查看次数

标签 统计

c++ ×1

non-type ×1

static ×1

templates ×1

variadic-templates ×1