Me too!
I found this article:
http://www.codeproject.com/managedcp...ligenerics.asp
It indicates that generics can be used for this very purpose. And it demos
the use of typeid:
generic<typename T> static INumericalOperations<T>^ GetNumericalAdapter()
{
Type^ typ = T::typeid;
if( typ == int::typeid)
{
return dynamic_cast<INumericalOperations<T>^>(gcnew
IntNumericalAdapter());
}
if( typ == float::typeid)
{
return dynamic_cast<INumericalOperations<T>^>(gcnew
FloatNumericalAdapter());
}
return nullptr;
}
But it seems there should be a better way than having a bunch of if
statements for each type that is likely to be templatized. Basically we
need a generic T to template T conversion routine.
Dick
"Rune Vistnes" <Rune
Vi*****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hey,
I am trying to wrap an unmanaged library in managed c++ so that I can use
this library in other .NET languages, such as C#. I've been successful for
the most part this far, but I'm having a hard time figuring out how to
wrap
template classes. I'm getting an C3231 compile error when I try to use the
generic type as a template type.
Here's an example from the MSDN C3231 compile error site:
template <class T> class A;
generic <class T>
ref class C {
void f() {
A<T> a; // C3231
}
};
Does anyone know how to work around this?
Best regards,
Rune Vistnes