title: C++ vector of CRTP shared pointers
body: <p>In my search for a way to store CRTP objects in a container, I found the following question: </p>
  
  <p><a href="https://stackoverflow.com/questions/24795012/a-polymorphic-collection-of-curiously-recurring-template-pattern-crtp-in-c">A polymorphic collection of Curiously Recurring Template Pattern (CRTP) in C++?</a></p>
  
  <p>I tryied the marked solution </p>
  
  <p><a href="https://stackoverflow.com/a/24795227/5475431">https://stackoverflow.com/a/24795227/5475431</a></p>
  
  <p>but the compiler is complainings erros like:</p>
  
  <pre><code>no known conversion for argument 1 from ‘std::shared_ptr&lt;DerivedA&gt;’ to ‘const std::shared_ptr&lt;BaseInterface&gt;&amp;’
  </code></pre>
  
  <p>here is my try:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;memory&gt;
  
  struct BaseInterface {
      virtual ~BaseInterface() {}
      virtual double interface() = 0;
  };
  
  template &lt;typename Derived&gt;
  class Base : BaseInterface {
  public:
      double interface(){
          return static_cast&lt;Derived*&gt;(this)-&gt;implementation();
  }
  };
  
  class DerivedA : public Base&lt;DerivedA&gt;{
  public:
       double implementation(){ return 2.0;}
  };
  
  class DerivedB : public Base&lt;DerivedB&gt;{
  public:
       double implementation(){ return 1.0;}
  };
  
  
  int main() {
      std::vector&lt;std::shared_ptr&lt;BaseInterface&gt;&gt; ar;
      ar.emplace_back(std::make_shared&lt;DerivedA&gt;());
  return 0;
  }
  </code></pre>
  
  <p>do you have any idea how to fix the compiler error, or how to solve the problem better?
  Thanks in advance</p>