Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Problems with serializing a shared_ptr
From: Stefan Ulbrich (stevie157_at_[hidden])
Date: 2009-11-16 08:08:13


Hello,

I want to add serialization support to the Eigen2 matrix class. It
works well (at least at compile time) until I try to serialize a
shared_ptr.

      boost::shared_ptr<MatrixXd> shape;

      template <typename Archive>
      void serialize(Archive& ar, const unsigned int version) {
        ar & BOOST_SERIALIZATION_NVP(shape);
      };

I receive a long error message that begins with the first error:

/usr/local/include/boost/type_traits/has_new_operator.hpp: In
instantiation of
'boost::detail::has_new_operator_impl<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >':
/usr/local/include/boost/type_traits/has_new_operator.hpp:109:
instantiated from 'boost::has_new_operator<Eigen::Matrix<double,
10000, 10000, 2, 10000, 10000> >'
/usr/local/include/boost/mpl/if.hpp:67: instantiated from
'boost::mpl::if_<boost::has_new_operator<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >,
boost
::mpl
::identity
<boost::archive::detail::heap_allocator<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >::has_new_operator>,
boost
::mpl
::identity
<boost::archive::detail::heap_allocator<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >::doesnt_have_new_operator> >'
/usr/local/include/boost/mpl/eval_if.hpp:37: instantiated from
'boost::mpl::eval_if<boost::has_new_operator<Eigen::Matrix<double,
10000, 10000, 2, 10000, 10000> >,
boost
::mpl
::identity
<boost::archive::detail::heap_allocator<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >::has_new_operator>,
boost
::mpl
::identity
<boost::archive::detail::heap_allocator<Eigen::Matrix<double, 10000,
10000, 2, 10000, 10000> >::doesnt_have_new_operator> >'
/usr/local/include/boost/archive/detail/iserializer.hpp:235:
instantiated from 'static T*
boost::archive::detail::heap_allocator<T>::invoke() [with T =
Eigen::Matrix<double, 10000, 10000, 2, 10000, 10000>]'
/usr/local/include/boost/archive/detail/iserializer.hpp:278:
instantiated from 'void
boost::archive::detail::pointer_iserializer<Archive,
T>::load_object_ptr(boost::archive::detail::basic_iarchive&, void*&,
unsigned int) const [with Archive = boost::archive::xml_iarchive, T =
Eigen::Matrix<double, 10000, 10000, 2, 10000, 10000>]'
BodySchema.cpp:110: instantiated from here
/usr/local/include/boost/type_traits/has_new_operator.hpp:85: error:
call of overloaded 'check_sig(int)' is ambiguous

Has anybody a hint for me what is missing in the matrix class?

second, could anybody please explain to me what
BOOST_SERIALIZATION_SHARED_PTR does and when I have to use it (only
saw it in the demo file).

Thank you,
Best regards
Stefan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net