mirror of
https://github.com/boostorg/serialization.git
synced 2026-02-24 04:12:28 +00:00
improve collection serialization with boost::move
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -40,7 +41,7 @@ struct archive_input_unordered_map
|
||||
detail::stack_construct<Archive, type> t(ar, v);
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
std::pair<typename Container::const_iterator, bool> result =
|
||||
s.insert(t.reference());
|
||||
s.insert(boost::move(t.reference()));
|
||||
// note: the following presumes that the map::value_type was NOT tracked
|
||||
// in the archive. This is the usual case, but here there is no way
|
||||
// to determine that.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <utility>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -40,7 +41,7 @@ struct archive_input_unordered_set
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
std::pair<typename Container::const_iterator, bool> result =
|
||||
s.insert(t.reference());
|
||||
s.insert(boost::move(t.reference()));
|
||||
if(result.second)
|
||||
ar.reset_object_address(& (* result.first), & t.reference());
|
||||
}
|
||||
@@ -59,7 +60,7 @@ struct archive_input_unordered_multiset
|
||||
detail::stack_construct<Archive, type> t(ar, v);
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::const_iterator result =
|
||||
s.insert(t.reference());
|
||||
s.insert(boost::move(t.reference()));
|
||||
ar.reset_object_address(& (* result), & t.reference());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace std{
|
||||
#include <boost/serialization/item_version_type.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace serialization {
|
||||
@@ -93,7 +94,7 @@ collection_load_impl(
|
||||
while(count-- > 0){
|
||||
detail::stack_construct<Archive, typename T::value_type> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
t.push_back(u.reference());
|
||||
t.push_back(boost::move(u.reference()));
|
||||
ar.reset_object_address(& t.back() , & u.reference());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/collections_load_imp.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -79,7 +80,7 @@ collection_load_impl(
|
||||
while(--count > 0){
|
||||
detail::stack_construct<Archive, T> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
last = t.insert.after(last, u.reference());
|
||||
last = t.insert.after(last, boost::move(u.reference()));
|
||||
ar.reset_object_address(&(*last) , & u.reference());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <boost/serialization/hash_collections_save_imp.hpp>
|
||||
#include <boost/serialization/hash_collections_load_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -45,7 +46,7 @@ struct archive_input_hash_map
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
std::pair<typename Container::const_iterator, bool> result =
|
||||
s.insert(t.reference());
|
||||
s.insert(boost::move(t.reference()));
|
||||
// note: the following presumes that the map::value_type was NOT tracked
|
||||
// in the archive. This is the usual case, but here there is no way
|
||||
// to determine that.
|
||||
@@ -72,7 +73,7 @@ struct archive_input_hash_multimap
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::const_iterator result
|
||||
= s.insert(t.reference());
|
||||
= s.insert(boost::move(t.reference()));
|
||||
// note: the following presumes that the map::value_type was NOT tracked
|
||||
// in the archive. This is the usual case, but here there is no way
|
||||
// to determine that.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <boost/serialization/hash_collections_save_imp.hpp>
|
||||
#include <boost/serialization/hash_collections_load_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -43,7 +44,7 @@ struct archive_input_hash_set
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
std::pair<typename Container::const_iterator, bool> result =
|
||||
s.insert(t.reference());
|
||||
s.insert(boost::move(t.reference()));
|
||||
if(result.second)
|
||||
ar.reset_object_address(& (* result.first), & t.reference());
|
||||
}
|
||||
@@ -63,7 +64,7 @@ struct archive_input_hash_multiset
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::const_iterator result
|
||||
= s.insert(t.reference());
|
||||
= s.insert(boost::move(t.reference()));
|
||||
ar.reset_object_address(& (* result), & t.reference());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/item_version_type.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <boost/serialization/utility.hpp>
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -59,7 +60,7 @@ inline void load_map_collection(Archive & ar, Container &s)
|
||||
detail::stack_construct<Archive, type> t(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::iterator result =
|
||||
s.insert(hint, t.reference());
|
||||
s.insert(hint, boost::move(t.reference()));
|
||||
ar.reset_object_address(& (result->second), & t.reference().second);
|
||||
hint = result;
|
||||
++hint;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <boost/serialization/version.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/detail/has_default_constructor.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
|
||||
// function specializations must be defined in the appropriate
|
||||
// namespace - boost::serialization
|
||||
@@ -47,7 +47,7 @@ void save(
|
||||
// in the future, but for now, one will have to work around it. This can
|
||||
// be done by serialization the optional<T> as optional<T *>
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::detail::has_default_constructor<T>::value
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
);
|
||||
const bool tflag = t.is_initialized();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -55,7 +56,7 @@ inline void load_set_collection(Archive & ar, Container &s)
|
||||
// borland fails silently w/o full namespace
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::iterator result =
|
||||
s.insert(hint, t.reference());
|
||||
s.insert(hint, boost::move(t.reference()));
|
||||
ar.reset_object_address(& (* result), & t.reference());
|
||||
hint = result;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
@@ -67,14 +68,14 @@ collection_load_impl(
|
||||
t.clear();
|
||||
boost::serialization::detail::stack_construct<Archive, T> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
t.push_front(u.reference());
|
||||
t.push_front(boost::move(u.reference()));
|
||||
typename BOOST_STD_EXTENSION_NAMESPACE::slist<T, Allocator>::iterator last;
|
||||
last = t.begin();
|
||||
ar.reset_object_address(&(*t.begin()) , & u.reference());
|
||||
while(--count > 0){
|
||||
detail::stack_construct<Archive, T> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
last = t.insert_after(last, u.reference());
|
||||
last = t.insert_after(last, boost::move(u.reference()));
|
||||
ar.reset_object_address(&(*last) , & u.reference());
|
||||
}
|
||||
}
|
||||
@@ -109,14 +110,14 @@ inline void load(
|
||||
t.clear();
|
||||
boost::serialization::detail::stack_construct<Archive, U> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
t.push_front(u.reference());
|
||||
t.push_front(boost::move(u.reference()));
|
||||
typename BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last;
|
||||
last = t.begin();
|
||||
ar.reset_object_address(&(*t.begin()) , & u.reference());
|
||||
while(--count > 0){
|
||||
detail::stack_construct<Archive, U> u(ar, item_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
last = t.insert_after(last, u.reference());
|
||||
last = t.insert_after(last, boost::move(u.reference()));
|
||||
ar.reset_object_address(&(*last) , & u.reference());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace std{
|
||||
#include <boost/archive/detail/basic_iarchive.hpp>
|
||||
#include <boost/serialization/access.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/item_version_type.hpp>
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user