【发布时间】:2020-09-01 09:41:48
【问题描述】:
VS 2005 -> 编译没有任何错误。
VS 2010 -> 编译时出现任何错误。
例如代码sn-p
template< bool f > struct static_assert;
template<> struct static_assert<true> { static_assert() {} };
编译器错误:
错误 C2332:“结构”:缺少标签名称
例如代码sn-p
template< typename T >
class abcd
{
struct xyz
{
xyz();
char c;
T tt;
};
public:
enum { value = sizeof(xyz)-sizeof(T) < sizeof(T) ? sizeof(xyz)-sizeof(T) : sizeof(T) };
};
编译器错误:
错误 C2332:“类”:缺少标签名称
任何建议。
【问题讨论】:
-
您需要发布实例化模板的代码。否则cannot duplicate。另外,为什么不直接使用 Visual Studio 2019 而不是使用十年前的 VS 2010?
-
@PaulMcKenzie 在 VS 2015 中尝试了代码,但同样的错误。
标签: c++ visual-studio-2010 templates visual-studio-2005