How to accomplish covariant return types when returning a shared_ptr?
Posted
by Kyle
on Stack Overflow
See other posts from Stack Overflow
or by Kyle
Published on 2010-04-22T02:02:49Z
Indexed on
2010/04/22
2:23 UTC
Read the original article
Hit count: 239
using namespace boost;
class A {};
class B : public A {};
class X {
virtual shared_ptr<A> foo();
};
class Y : public X {
virtual shared_ptr<B> foo();
};
The return types aren't covariant (nor are they, therefore, legal), but they would be if I was using raw pointers instead. What's the commonly accepted idiom to work around this, if there is one?
© Stack Overflow or respective owner