小编rya*_*yan的帖子

在可变参数模板模板参数中使用默认模板参数

我发现下面的最小例子适用于gcc和clang甚至Visual Studio,但它不能用icc编译.我试图确定这是否是有效的C++,但我无法找到回答我的问题的标准的相关部分,因为这是几个不同的概念组合.

// struct with multiple template parameters
template<typename A, typename B = int>
struct C
{

};

// struct that tries to use C's default second parameter without specifying it
template<typename D, template<typename E, typename ...> class F>
struct G
{
  F<D> h;
};

int main()
{
  G<char, C> i;
}
Run Code Online (Sandbox Code Playgroud)

使用icc(16.0.3),编译会出现以下错误:

struct.cpp(12): error: too few arguments for template template parameter "F"
    F<D> h;

          detected during instantiation of class "G<D, F> [with D=char, F=C]" at line 17
Run Code Online (Sandbox Code Playgroud)

这是有效的C++吗?

对我来说似乎应该是,因为 …

c++ icc template-templates variadic-templates c++11

9
推荐指数
1
解决办法
592
查看次数

标签 统计

c++ ×1

c++11 ×1

icc ×1

template-templates ×1

variadic-templates ×1