Subject: [Boost-bugs] [Boost C++ Libraries] #13478: multi_index_container serialization of non copyable types
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-03-13 08:34:46
#13478: multi_index_container serialization of non copyable types
-------------------------------------------------+-------------------------
Reporter: Sébastien Paris <sebastien.paris@â¦> | Owner: JoaquÃn M
| López Muñoz
Type: Bugs | Status: new
Milestone: To Be Determined | Component: multi_index
Version: Boost 1.66.0 | Severity: Problem
Keywords: serialization non-copyable |
-------------------------------------------------+-------------------------
A multi_index container holding non-copyable types fails to serialize
because of delayed insertion through {{{std::pair<node_type*,bool>
insert_(const Value& v,Variant variant)}}} in
multi_index_container.hpp:555 happening in {{{void load(Archive& ar,const
unsigned int version)}}} in multi_index_container.hpp:940
The insertion should use a rvalue reference overload moving the previously
loaded value.
Minimal example:
{{{
template<class Archive>
void check_serialize(Archive &ar)
{
using non_copyable_type = std::unique_ptr<int>;
using non_copyable_multi_index = boost::multi_index_container
< non_copyable_type
, boost::multi_index::indexed_by
< boost::multi_index::hashed_unique
< boost::multi_index::const_mem_fun
< non_copyable_type
, typename non_copyable_type::pointer
, &non_copyable_type::get
>
>
>
>;
non_copyable_multi_index mu; // fine
if constexpr (Archive::is_saving::value)
ar << boost::serialization::make_nvp("mu",mu); // fine
else
ar >> boost::serialization::make_nvp("mu",mu); // error
}
}}}
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13478> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2018-03-13 08:38:47 UTC