What’s the appropriate way to get the non-handle type in the following code:
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
Also, the usage of handle type as a template parameter is mandatory (this is a part of bigger example, where I can’t simply change the template type to String instead of String^).
gcnew always returns a handle (^).
So here is something you can try. Not sure if it really meets your needs –
template ref class SuperClass
{
public:
void Method()
{
Type^ x = gcnew Type(“Hello”);
}
};