Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 207

How to accomplish covariant return types when returning a shared_ptr?

$
0
0
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?


Viewing all articles
Browse latest Browse all 207

Trending Articles