title: Boost::serialization and boost::mpi to broadcast derived class via base class pointer
body: <p>I am trying to use boost::mpi::broadcast to send a derived class to all nodes via a base class pointer.  To do this, I am using the boost::serialization library to serialize my classes.  My code, however, does not compile and I get the errors "class boost::mpi::packed_skeleton_iarchive’ has no member named ‘append’" and "class boost::mpi::packed_skeleton_iarchive’ has no member named ‘reset’."</p>
  
  <p>Here is the rough source code for the program:</p>
  
  <pre><code>// Base.hpp
  #include &lt;boost/serialization/serialization.hpp&gt;
  
  class Base
  {
      public:
          Base() {}
          virtual ~Base() {}
  
          virtual void foo() = 0;
      private:
          friend class boost::serialization::access;
  
          template&lt;class Archive&gt;
          void serialize( Archive&amp; /*ar*/, const unsigned int /*version*/ ) {}
  }
  
  // Derived.hpp
  #include &lt;boost/serialization/serialization.hpp&gt;
  #include &lt;boost/serialization/shared_ptr.hpp&gt;
  #include &lt;boost/serialization/vector.hpp&gt;
  #include &lt;boost/serialization/base_object.hpp&gt;
  #include &lt;boost/serialization/export.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;vector&gt;
  
  #include "Base.hpp"
  
  class Derived : public Base
  {
      public:
          Derived( int param );
          virtual ~Derived();
  
          void foo();
      private:
          int param_;
          std::vector&lt; boost::shared_ptr &gt; bar_;
  
          friend class boost::serialization::access;
  
          template&lt;class Archive&gt;
          void serialize( Archive&amp; ar, const unsigned int /*version*/ )
          {
              ar &amp; param_;
              ar &amp; bar_;
  
              ar &amp; boost::serialization::base_object&lt; Base &gt;( *this );
          }
  }
  
  namespace boost
  {
      namespace serialization
      {
          template&lt;class Archive&gt;
          void load_construct_data( Archive&amp; /*ar*/, Derived* d,
              const unsigned int /*v*/ )
          {
              ::new(d) Derived( 0 );
          }
      }
  }
  
  BOOST_CLASS_EXPORT_KEY( Derived )
  
  // Derived.cpp
  #include "Derived.hpp"
  
  Derived::Derived( int param ) : param_( param ) {}
  Derived::~Derived(){}
  
  Derived::foo()
  {
      // some stuff
  }
  
  BOOST_CLASS_EXPORT_IMPLEMENT( Derived )
  
  // Main.cpp
  #include &lt;boost/mpi.hpp&gt;
  #include &lt;boost/serialization/serialization.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  
  #include "Derived.hpp"
  
  int main( int argc, char* argv[] )
  {
      boost::shared_ptr&lt; Base &gt; sp;
  
      if ( world.rank() == 0 )
      {
          sp = boost::shared_ptr&lt; Base &gt;( new Derived( 5 ) );
  
          boost::mpi::broadcast( world, sp, 0 );
  
          // produce some stuff
      } else
      {
          while ( 1 )
          {
             // consume some stuff
          }
      }
  
      return 0;
  }
  
  BOOST_SERIALIZATION_ASSUME_ABSTRACT( Base )
  </code></pre>
  
  <p>I found only one Google Groups discussion about this problem but no solution so far <a href="https://groups.google.com/forum/#!msg/boost-developers-archive/Ee9_ilEDO7s/cJTy-8v5lEcJ" rel="nofollow">https://groups.google.com/forum/#!msg/boost-developers-archive/Ee9_ilEDO7s/cJTy-8v5lEcJ</a>.  How can I get this to compile?  I am using openmpi 1.2.8-17.4, gcc 4.5.1 and boost 1.54.</p>