non-handle
次のコードで型を取得する適切な方法は何ですか。
template <typename Type> ref class SuperClass
{
public:
void Method()
{
Type x = gcnew ???? (...);
// I want it to be instantiated into 'String^ x = gcnew String(...).
// Is there a way to "dereference" the handle type in C++ \ CLI ?
}
};
SuperClass<String^> superClass;
superClass.Method(); // <---- Won't compile
また、テンプレートパラメータとしてのハンドルタイプの使用は必須ですString
(これは、テンプレートタイプを代わりに単純に変更できない、より大きな例の一部ですString^
)。