[serialization] Problems with serializing a shared_ptr
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
Stefan Ulbrich wrote:
Has anybody a hint for me what is missing in the matrix class?
what compiler?
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).
This is required to permit the implementation to work for compilers which fail to support partial template specialization. Robert Ramey
Thank you, Best regards Stefan
participants (2)
-
Robert Ramey
-
Stefan Ulbrich