title: How to accomplish covariant return types when returning a shared_ptr?
body: <pre><code>using namespace boost;
  
  class A {};
  class B : public A {};
  
  class X {
    virtual shared_ptr&lt;A&gt; foo();
  };
  
  class Y : public X {
    virtual shared_ptr&lt;B&gt; foo();
  };
  </code></pre>
  
  <p>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?</p>