A bit stupified by why the following complies just fine:
template<typename T> struct Foo { template<int i> struct Bar { typedef int BarSizeType; }; }; template<typename T, int i> void do_something(typename Foo<T>::Bar<i>::BarSizeType arg) { // ... } But this doesn't:
template<typename T, typename T2> struct Foo { template<int i> struct Bar { typedef int BarSizeType; }; }; template<typename T, int i> void do_something(typename Foo<T, T>::Bar<i>::BarSizeType arg) { // ... } The compilation errors are:
error C2143: syntax error : missing ')' before '<'
error C2143: syntax error : missing ';' before '<'
error C2988: unrecognizable template declaration/definition
error C2059: syntax error : '<'
error C2039: 'BarSizeType' : is not a member of '`global namespace''
error C2059: syntax error : ')'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
Any way I can make this compile, without making drastic changes to the code? I'm using vs2012 compiler.