title: shared_from_this when inheriting from class defined by third party
body: <p>I've read many posts on stack-overflow about shared_from_this, bad_weak_ptr exceptions, and multiple inheritance while trying to research my problem. All of them propose you inherit a base class from enable_shared_from_this, and then derive from that. Well, what does one do when the class you have to derive from is a coming from a third party library that you cannot edit?</p>
  
  <p>Example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  class ThirdPartyClass
  {
  public:
      ThirdPartyClass() {}
      ThirdPartyClass(const ThirdPartyClass &amp;) = delete;
      virtual ~ThirdPartyClass() {};
  };
  
  class A : public ThirdPartyClass, std::enable_shared_from_this&lt;A&gt;
  {
  public:
      A():ThirdPartyClass(){}
      virtual ~A(){}
  
      void Foo();
  };
  
  void DoStuff(std::shared_ptr&lt;A&gt; ptr)
  {
      std::cout &lt;&lt; "Good job if you made it this far!" &lt;&lt; std::endl;
  }
  
  void A::Foo()
  {
      DoStuff(shared_from_this());    // throws here
  }
  
  int main() {
      std::shared_ptr&lt;A&gt; a = std::make_shared&lt;A&gt;();
      a-&gt;Foo();
      return 0;
  }
  </code></pre>