Possible duplicate:
Where and why do I need to put the keywords "template" and "typename"?
When I try to compile the following code in VS 2012, I get errors in the typedef lines of the Consumer class, starting with:
error C2143: syntax error : missing ';' before '<'
Is this a compiler problem or is the code no longer valid with C ++? (The project is extracted from, of course, used to build without problems in older versions of VS - and gcc iirc - but that was about 10 years ago!)
struct TypeProvider { template<class T> struct Container { typedef vector<T> type; }; }; template<class Provider> class Consumer { typedef typename Provider::Container<int>::type intContainer; typedef typename Provider::Container<double>::type doubleContainer; };
There is a workaround for it, but I'm just wondering if this is needed:
struct TypeProvider { template<typename T> struct Container { typedef vector<T> type; }; }; template<template<class T> class Container, class Obj> struct Type { typedef typename Container<Obj>::type type; }; template<typename Provider> class TypeConsumer { typedef typename Type<Provider::Container, int>::type intContainer; typedef typename Type<Provider::Container, double>::type doubleContainer; };
source share