次のケースは、MS Visual Studioでは正常にコンパイルされますが、g++4.6ではコンパイルされません。
コンパイル:
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) {} };
結果:
../testlibrary/testlibrary.h:16:34: error: expected type-specifier
../testlibrary/testlibrary.h:16:34: error: expected ‘>’
使ったら気に入らないようです
get_type<T>::type_
テンプレート引数のデフォルトとして。MS Visual Studio(Express 10)は、これを正常にコンパイルします。これをコンパイルするためにg++を取得するためにどのような変更を加えることができますか?