【发布时间】:2021-02-21 18:50:47
【问题描述】:
我正在尝试专门针对特定类型的可变参数模板类。
我正在努力实现这一目标:
template<typename... Ts>
class myclass
{
///...
};
template<>
class myclass<int... N>
{
///...
};
我得到了这个错误:
error C2760: syntax error: unexpected token 'int', expected 'expression'
error C2187: syntax error: '...' was unexpected here
error C2065: 'N': undeclared identifier
error C2913: explicit specialization; 'ex::vec' is not a specialization of a class templa
谁能提示我做错了什么?
【问题讨论】:
-
你不能用值来专门化为类型定义的类。
-
你打算如何使用它?请添加示例。
-
为确保我理解,您希望您的专长处理
myclass<int>或myclass<int, int>或myclass<int, ..., int>,对吗? -
@NathanOliver,正确。
-
请提供该模板的用例示例。您的定义示例没有意义。
标签: c++ templates variadic-templates