【发布时间】:2016-12-29 20:23:56
【问题描述】:
我正在尝试实现一个具有 2 个算术类型专业化的 Expression 类。这是默认类:
template<typename Left, typename Op, typename Right, typename std::enable_if<!std::is_arithmetic<Left>::value, Left>::type* = nullptr>
class Expression { /* ... */ }
这是两个专业:
template<typename Left, typename Op, typename Right, typename std::enable_if<std::is_arithmetic<Left>::value, Left>::type* = nullptr>
class Expression { /* ... */ };
template<typename Left, typename Op, typename Right, typename std::enable_if<std::is_arithmetic<Right>::value, Right>::type* = nullptr>
class Expression { /* ... */ };
如果我现在编译我的代码,我会得到这个错误:
错误 C3855“表达式”:模板参数“__formal”与声明向量不兼容
如何解决我使用模板和专业化或虚拟类型的问题。
【问题讨论】:
-
请分享显示相同错误的最小代码示例。根据您提供的信息,很难猜测出什么问题。
-
我在示例代码中的任何位置都没有看到名为
__formal的模板参数(这是一个保留标识符)或名为Vector的声明。请发帖minimal reproducible example。
标签: c++ c++11 templates template-specialization typetraits