diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:45:20 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:46:37 +0900 |
commit | 733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /boost/serialization/slist.hpp | |
parent | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff) | |
download | boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2 boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip |
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/serialization/slist.hpp')
-rw-r--r-- | boost/serialization/slist.hpp | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/boost/serialization/slist.hpp b/boost/serialization/slist.hpp index 4072076fa4..424aa51466 100644 --- a/boost/serialization/slist.hpp +++ b/boost/serialization/slist.hpp @@ -28,9 +28,10 @@ namespace std{ #include BOOST_SLIST_HEADER #include <boost/serialization/collections_save_imp.hpp> -#include <boost/serialization/collections_load_imp.hpp> #include <boost/serialization/split_free.hpp> #include <boost/serialization/nvp.hpp> +#include <boost/serialization/detail/stack_constructor.hpp> +#include <boost/serialization/detail/is_default_constructible.hpp> namespace boost { namespace serialization { @@ -53,31 +54,38 @@ inline void load( BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator> &t, const unsigned int file_version ){ - // retrieve number of elements - t.clear(); - // retrieve number of elements - collection_size_type count; - ar >> BOOST_SERIALIZATION_NVP(count); - if(collection_size_type(0) == count) - return; - item_version_type item_version(0); const boost::archive::library_version_type library_version( ar.get_library_version() ); + // retrieve number of elements + item_version_type item_version(0); + collection_size_type count; + ar >> BOOST_SERIALIZATION_NVP(count); if(boost::archive::library_version_type(3) < library_version){ ar >> BOOST_SERIALIZATION_NVP(item_version); } - boost::serialization::detail::stack_construct<Archive, U> u(ar, item_version); - ar >> boost::serialization::make_nvp("item", u.reference()); - t.push_front(u.reference()); - typename BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last; - last = t.begin(); - while(--count > 0){ - boost::serialization::detail::stack_construct<Archive, U> - u(ar, file_version); + if(detail::is_default_constructible<U>()){ + t.resize(count); + typename BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator hint; + hint = t.begin(); + while(count-- > 0){ + ar >> boost::serialization::make_nvp("item", *hint++); + } + } + else{ + t.clear(); + boost::serialization::detail::stack_construct<Archive, U> u(ar, item_version); ar >> boost::serialization::make_nvp("item", u.reference()); - last = t.insert_after(last, u.reference()); - ar.reset_object_address(& (*last), & u.reference()); + t.push_front(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()); + ar.reset_object_address(&(*last) , & u.reference()); + } } } |