次のコードを検討してください。
public ref class Factory
{
public:
generic <typename T> where T : value class, System::ValueType
static System::Nullable<T> Create()
{
return System::Nullable<T>();
}
};
Visual C++ 2008 は次のエラーを吐き出します。
error C2440: 'return' : cannot convert from 'System::Nullable<T>' to 'System::Nullable<T>'
「System::Nullable」型をユーザー定義型に置き換えると、問題なく動作します。
generic <typename T> where T : value class, System::ValueType
public value class MyType
{ };
public ref class Factory
{
public:
generic <typename T> where T : value class, System::ValueType
static MyType<T> Create()
{
return MyType<T>();
}
};
これはある種の VC++ バグですか、それともここで何か不足していますか?