Re: [Boost-users] boost::serialization::array for Orocos RTT
Sir,
I gave the following includes
#include
On 3/08/2016 23:29, Sambeet Panigrahi wrote:
I gave the following includes #include
#include I know boost::array exists,but does boost::serialization::array exist?Because in the namespace serialization in the boost/serialization/array.hpp, I could not find such a template.
namespace boost { namespace serialization { [...] template<class T> class array_wrapper : public wrapper_traits
>
Looks like it's called array_wrapper instead of array in your version. Which is odd, since you claimed to be using 1.44, and these say differently: http://www.boost.org/doc/libs/1_44_0/boost/serialization/array.hpp https://github.com/boostorg/serialization/blob/1b9dc31ba/include/boost/seria... If you obtained the Boost library from an SDK vendor instead of directly from Boost, you should probably ask them why it is different.
Sorry, That's my mistake.This was boost1.61.Been trying out a lot of
versions :). Anyways I found that boost1.54 had this template as array rest
all have this array_wrapper.So Orocos RTT works out with Boost 1.54 only.
On Wed, Aug 3, 2016 at 4:59 PM, Sambeet Panigrahi
Sir, I gave the following includes #include
#include I know boost::array exists,but does boost::serialization::array exist?Because in the namespace serialization in the boost/serialization/array.hpp, I could not find such a template.
namespace boost { namespace serialization {
// traits to specify whether to use an optimized array serialization
template <class Archive> struct use_array_optimization : boost::mpl::alwaysboost::mpl::false_ {};
template<class T> class array_wrapper : public wrapper_traits
> { private: array_wrapper & operator=(const array_wrapper & rhs); public: // note: I would like to make the copy constructor private but this breaks // make_array. So I try to make make_array a friend - but that doesn't // build. Need a C++ guru to explain this! template<class S> friend const boost::serialization::array_wrapper<T> make_array( T* t, S s); array_wrapper(const array_wrapper & rhs) : m_t(rhs.m_t), m_element_count(rhs.m_element_count) {} public: array_wrapper(T * t, std::size_t s) : m_t(t), m_element_count(s) {}
// default implementation template<class Archive> void serialize_optimized(Archive &ar, const unsigned int, mpl::false_ ) const { // default implemention does the loop std::size_t c = count(); T * t = address(); while(0 < c--) ar & boost::serialization::make_nvp("item", *t++); }
// optimized implementation template<class Archive> void serialize_optimized(Archive &ar, const unsigned int version, mpl::true_ ) { boost::serialization::split_member(ar, *this, version); }
// default implementation template<class Archive> void save(Archive &ar, const unsigned int version) const { ar.save_array(*this,version); }
// default implementation template<class Archive> void load(Archive &ar, const unsigned int version) { ar.load_array(*this,version); }
// default implementation template<class Archive> void serialize(Archive &ar, const unsigned int version) { typedef typename boost::serialization::use_array_optimization<Archive>::template apply< typename remove_const< T >::type >::type use_optimized; serialize_optimized(ar,version,use_optimized()); }
T * address() const { return m_t; }
std::size_t count() const { return m_element_count; }
private: T * const m_t; const std::size_t m_element_count; };
template
inline const array_wrapper< T > make_array( T* t, S s){ const array_wrapper< T > a(t, s); return a; } } } // end namespace boost::serialization
// I can't figure out why BOOST_NO_CXX11_HDR_ARRAY // has been set for clang-11. So just make sure // it's reset now. Needs further research!!!
#if defined(_LIBCPP_VERSION) #undef BOOST_NO_CXX11_HDR_ARRAY #endif
#ifndef BOOST_NO_CXX11_HDR_ARRAY #include <array> namespace boost { namespace serialization { // implement serialization for std::array template
void serialize(Archive& ar, std::array & a, const unsigned int /* version */) { ar & boost::serialization::make_nvp( "elems", *static_cast (static_cast (a.data())) ); } } } // end namespace boost::serialization #endif
participants (2)
-
Gavin Lambert
-
Sambeet Panigrahi