【发布时间】:2010-07-21 00:01:19
【问题描述】:
我有一个模板类,我在其中专门研究了几个方法。出于某种原因,当我为结构添加专业化时,它似乎与 bool 的专业化冲突。我收到类型转换错误,因为它试图设置 struct = bool (解决错误的专业化)。这是一些代码
.h:
typedef struct foo {
...
}
template <class T> class bar {
template <class T> void method1() {...}
template <> void method1<bool>() {...}
template <> void method1<foo>() {...}
}
.cpp
template class bar<bool>;
template class bar<foo>;
我在 method1<bool> 中遇到错误,因为它设置 T=foo 而不是将其解析为 method1<foo>。
有什么想法吗?
【问题讨论】: