Is it possible to define covariancy/contravariancy in generic interface in C++/CLI?

  • Thread starter Thread starter poszepszynski
  • Start date Start date
P

poszepszynski

Guest
There is a nice article on covariancy and contravariancy in C#. Is it possible to implement such a covariant/contravariant interface in the C++/CLI?

interface IMyGeneric<out T> { }
interface IMyOtherGeneric<out T> { }

class MyGeneric<T> : IMyGeneric<T> { }
class MyOtherGeneric<T> : IMyOtherGeneric<T> { }

void Foo(IMyGeneric<IMyOtherGeneric<string>> arg) { }

void Bar()
{
var mgs = new MyGeneric<MyOtherGeneric<string>>();
Foo(mgs);
}

How can I, or can I at all, implement it in C++/CLI?

Continue reading...
 
Back
Top