为什么这个不是完整的模板专业化
why is this not full template specialization
我想在什么'通行证上专业地专业化一些功能,我想知道为什么这不编译?(这是一个课程的一部分):
struct Passes {
enum Value {
First,
Second
};
};
template<Passes::Value Pass_t> void output();
template<> void output<Passes::Second>();
建议?我使用英特尔编译器收到的错误是:
error: an explicit template argument list is not allowed on this declaration
建议?
首先,发布错误消息。我认为您有一个与我的类似的(一旦我将代码片段扩展到我可以编译的东西):
explicit specialization in non-namespace scope
然后,阅读错误消息。正如它所说,您只能在命名空间范围中专业一个模板,而不是在课堂内:
struct Thing {
// Primary template declared as a class member
template<Passes::Value Pass_t> void output();
};
// Specialisation declared at namespace scope
template<> void Thing::output<Thing::Passes::Second>();
相关文章:
- 为什么在班级专业化上会出现错误?
- 为什么这个模板代码不选择部分专业化
- 为什么没有选择模板专业化?
- 为什么这不是函数模板的部分专业化
- 为什么VS2017拒绝我的功能模板专业化,而不是VS2015拒绝
- 为什么模板专业化需要内联?
- 为什么我们不能在模板专业化的开始/中间使用可变参数模板(以及如何模拟)?
- 为什么有这么多std::swap的专业化
- 为什么不允许对成员函数的模板专业化
- 为什么未经声明未从.cpp文件拾取模板函数的完整专业化
- 为什么这个不是完整的模板专业化
- 为什么这是部分专业化?(我能做什么?
- 为什么内联模板专业化有帮助?我应该这样做吗
- 为什么要使用模板专业化
- 为什么不能在完全专业化中引入新的模板参数?
- 为什么类中不允许函数模板专业化
- 为什么我的模板专业化不起作用
- 为什么显式专业化和部分专业化之间的语法差异
- 为什么未使用的部分专业化没有错误
- 为什么没有针对 std::shared_ptr<T[]> 的专业化?