我有以下(最小化的)代码,在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\u type”是依赖类型时,我总是在专门化上得到一个C2770:invalid explicit template参数错误。请注意,这段代码实际上足以生成错误-一个空的main就足以编译它,甚至不需要实例化模板。
如果索引类型不是依赖类型,则可以正常工作。你知道为什么在VC2010中会这样吗,这是不是标准的行为或者一个bug,我是否可以解决它?