The following case compiles fine in MS Visual Studio, but not in g++ 4.6.
Compiling:
template <typename T>
struct get_type
{ typedef void type_;};
template <>
struct get_type<float>
{ typedef float type_; };
template <>
struct get_type<int>
{ typedef int type_; };
template <typename T, typename P=get_type<T>::type_> // <--- line 16
struct get_destroy_type
{ static inline void exec(P a) {} };
Results in:
../testlibrary/testlibrary.h:16:34: error: expected type-specifier
../testlibrary/testlibrary.h:16:34: error: expected ‘>’
Doesn’t seem to like it when I use
get_type<T>::type_
as the template argument default. MS Visual Studio (Express 10) compiles this fine. What changes can I make to get g++ to compile this?
Use
typenameto disambiguate: