#13478 closed Bugs (fixed)
multi_index_container serialization of non copyable types
Reported by: | Owned by: | Joaquín M López Muñoz | |
---|---|---|---|
Milestone: | To Be Determined | Component: | multi_index |
Version: | Boost 1.66.0 | Severity: | Problem |
Keywords: | serialization non-copyable | Cc: |
Description
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 }
Change History (3)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Hi Sébastien,
Thank you for the bug report. Also, your proposed fix is correct.
It's going to take me a couple of days till I find the time to change this in develop. As we're now closing Boost 1.67, the change will go in Boost 1.68.
Best regards,
comment:3 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Proposed resolution: modify multi_index_container.hpp:954-955 from
to