Visual Studio 报错信息:未专用化的类 模板 不能用作 模板 变量,该变量属于 模板 参数“_Ty”,应为 real 类型
1 2 3 4 5 6 7 8 9 10 11
| template <typename channel, typename VLD, typename RDY> class IOChannelInterface {};
template <typename channel> struct InputChannel : public IOChannelInterface<channel, sc_in, sc_out> {}
template <typename channel> struct OutputChannel : public IOChannelInterface<channel, sc_out, sc_in> {}
|
这里 sc_in 和 sc_out 本身是模板,作为另一个模板 IOChannelInterface 的模板变量,导致错误。
将一个模板作为另一个模板的模板参数时候必须声明其是一个模板,而不能直接使用它作为一种新类型。
即相应 typename 要改为 template<> typename。
修改后的模板格式如下:
1 2 3 4 5
| template <typename channel, template <typename A> typename VLD, template <typename B> typename RDY> class IOChannelInterface {};
|