title: can't deserialize with boost::serialization and shared_ptr
body: <p>I implemented the class structure below. I would like to serialize these objects. </p>
  
  <pre><code>class Base
  {
  public:
    Base(void) = default;
  
    virtual double func(void) const = 0;
  
  
  private:
    friend class boost::serialization::access;
    template&lt;class Archive&gt;
    void serialize(Archive &amp; ar, const unsigned int version)
    {}
  }; 
  
  class DerivedA : public Base
  {
  public:
    DerivedA(void) = default;
    DerivedA(double a)
    : a_(a) {}
  
    virtual double func(void) const
    {
      return std::exp(a_);
    }
  
  private:
    double a_; 
  
    friend class boost::serialization::access;
    template&lt;class Archive&gt;
    void serialize(Archive &amp; ar, const unsigned int version)
    {
      ar &amp; a_;
    }
  }; 
  
  
  class DerivedB : public Base
  {
  public:
    DerivedB(void) = default;
    DerivedB(double b)
    : b_(b) {}
  
    virtual double func(void) const
    {
      return std::log(b_);
    }
  
   private:
     double b_; 
  
     friend class boost::serialization::access;
     template&lt;class Archive&gt;
     void serialize(Archive &amp; ar, const unsigned int version)
     {
       ar &amp; b_;
     }
   }; 
  </code></pre>
  
  <p>I want to create a vector of shared_ptr to these objects and serialize and deserialize them. Serialization seems ok, but I can't get them deserialized. Any ideas?</p>
  
  <pre><code>void out(void)
  {
    std::vector&lt;std::shared_ptr&lt;Base&gt;&gt; objects;
    std::shared_ptr&lt;Base&gt; m1(new DerivedA(1.0));
    std::shared_ptr&lt;Base&gt; m2(new DerivedB(4.0));
    objects.push_back(m1);
    objects.push_back(m2);
  
    std::ofstream ofs("filename");
    boost::archive::text_oarchive oa(ofs);
  
    for(auto o : objects)
    {
      oa &lt;&lt; *o;
    }
  }
  
  void in(void)
  {
    std::ifstream ifs(filename);
    boost::archive::text_iarchive ia(ifs);
  
    std::vector&lt;std::shared_ptr&lt;Base&gt;&gt; objects;
  
    std::shared_ptr&lt;Base&gt; m1(new DerivedA());
    ia &gt;&gt; *m1;
    models.push_back(m1);
    std::shared_ptr&lt;Base&gt; m2(new DerivedB());
    ia &gt;&gt; *m2;
    models.push_back(m2);  
  }
  </code></pre>
  
  <p>Cheers, Mike</p>