Linux の GCC では、次のコードは適切にコンパイルされます。しかし、Visual Studio ではエラー C2893 が発生します。あなたはなにか考えはありますか ?
struct A
{
};
struct B
{
typedef A Data;
};
struct C
{
typedef B Data;
};
template<typename Type>
typename Type::Data::Data test( Type in)
{
return Type::Data::Data();
}
int main(){
C c;
C::Data::Data a;//works
test(c);//error C2893: The specialization of the function template 'Type :: Data :: {ctor} test (Type)' failed
}
どうもありがとう
Avakar による解決策: Data::Data は Data 型のコンストラクターを参照するため、次のイディオムを使用する必要があります。
typename identity<typename Type::Data>::type::Data