我有以下(最小化)代码,它在 VC2005 中工作,但在 2010 年不再工作。
template <typename TDataType>
class TSpecWrapper
{
public:
typedef typename TDataType::parent_type index_type;
public:
template <bool THasTriangles>
void Spec(index_type& io_index)
{ std::cout << "False version" << std::endl; }
template <>
void Spec<true>(index_type& io_index)
{ std::cout << "True version" << std::endl; }
};
似乎当“index_type”是依赖类型时,我总是在专业化上得到一个 C2770: invalid explicit template argument(s) 错误。请注意,此代码实际上足以生成错误 - 一个空的 main 足以编译它,甚至不需要实例化模板。
如果 index_type 不是依赖类型,它可以正常工作。任何想法为什么在 VC2010 中如此,如果这实际上是标准行为或错误,如果我可以解决它?