kna*_*ten 10 c++ templates template-meta-programming visual-c++-2012
我继承了一个大量使用模板元编程的项目,现在正处于从Visual Studio 2010升级到2012的过程中.一些模板代码在2012年不再有效.我已经提炼了一个最小的例子:
template <typename T, int i>
class MyClass
{
private:
typedef typename T::Nested<i> Found;
};
Run Code Online (Sandbox Code Playgroud)
给出此错误消息:
source.cpp(5): error C2059: syntax error : '<'
source.cpp(6) : see reference to class template instantiation 'MyClass<T,i>' being compiled
source.cpp(5): error C2238: unexpected token(s) preceding ';'
Run Code Online (Sandbox Code Playgroud)
进一步下来MyClass,我可以使用T::Nested<i>,这只是typedef不起作用.
此示例在2010年编译,但不在2012年编译.此代码有什么问题?