summaryrefslogtreecommitdiff
path: root/boost/serialization
diff options
context:
space:
mode:
Diffstat (limited to 'boost/serialization')
-rw-r--r--boost/serialization/deque.hpp38
-rw-r--r--boost/serialization/detail/is_default_constructible.hpp45
-rw-r--r--boost/serialization/detail/stack_constructor.hpp2
-rw-r--r--boost/serialization/forward_list.hpp51
-rw-r--r--boost/serialization/hash_collections_load_imp.hpp2
-rw-r--r--boost/serialization/list.hpp45
-rw-r--r--boost/serialization/map.hpp63
-rw-r--r--boost/serialization/set.hpp59
-rw-r--r--boost/serialization/shared_ptr_helper.hpp1
-rw-r--r--boost/serialization/slist.hpp46
-rw-r--r--boost/serialization/state_saver.hpp2
-rw-r--r--boost/serialization/string.hpp61
-rw-r--r--boost/serialization/unordered_collections_load_imp.hpp2
-rw-r--r--boost/serialization/vector.hpp56
14 files changed, 292 insertions, 181 deletions
diff --git a/boost/serialization/deque.hpp b/boost/serialization/deque.hpp
index 7012902..e182f7b 100644
--- a/boost/serialization/deque.hpp
+++ b/boost/serialization/deque.hpp
@@ -21,7 +21,8 @@
#include <boost/config.hpp>
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
+#include <boost/serialization/detail/stack_constructor.hpp>
+#include <boost/serialization/detail/is_default_constructible.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost {
@@ -44,14 +45,33 @@ inline void load(
std::deque<U, Allocator> &t,
const unsigned int /*file_version*/
){
- boost::serialization::stl::load_collection<
- Archive,
- std::deque<U, Allocator>,
- boost::serialization::stl::archive_input_seq<
- Archive, std::deque<U, Allocator>
- >,
- boost::serialization::stl::no_reserve_imp<std::deque<U, Allocator> >
- >(ar, t);
+ 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);
+ }
+ if(detail::is_default_constructible<U>()){
+ t.resize(count);
+ typename std::deque<U, Allocator>::iterator hint;
+ hint = t.begin();
+ while(count-- > 0){
+ ar >> boost::serialization::make_nvp("item", *hint++);
+ }
+ }
+ else{
+ t.clear();
+ while(count-- > 0){
+ detail::stack_construct<Archive, U> u(ar, item_version);
+ ar >> boost::serialization::make_nvp("item", u.reference());
+ t.push_back(u.reference());
+ ar.reset_object_address(& t.back() , & u.reference());
+ }
+ }
}
// split non-intrusive serialization function member into separate
diff --git a/boost/serialization/detail/is_default_constructible.hpp b/boost/serialization/detail/is_default_constructible.hpp
new file mode 100644
index 0000000..d928e69
--- /dev/null
+++ b/boost/serialization/detail/is_default_constructible.hpp
@@ -0,0 +1,45 @@
+#ifndef BOOST_SERIALIZATION_DETAIL_IS_DEFAULT_CONSTRUCTIBLE_HPP
+#define BOOST_SERIALIZATION_DETAIL_IS_DEFAULT_CONSTRUCTIBLE_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// is_default_constructible.hpp: serialization for loading stl collections
+//
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
+ #include <type_traits>
+ namespace boost{
+ namespace serialization {
+ namespace detail {
+
+ template<typename T>
+ struct is_default_constructible : std::is_default_constructible<T> {};
+
+ } // detail
+ } // serializaition
+ } // boost
+#else
+ #include <boost/type_traits/has_trivial_constructor.hpp>
+ namespace boost{
+ namespace serialization {
+ namespace detail {
+
+ template<typename T>
+ struct is_default_constructible : boost::has_trivial_constructor<T> {};
+
+ } // detail
+ } // serializaition
+ } // boost
+#endif
+
+#endif // BOOST_SERIALIZATION_DETAIL_IS_DEFAULT_CONSTRUCTIBLE_HPP
diff --git a/boost/serialization/detail/stack_constructor.hpp b/boost/serialization/detail/stack_constructor.hpp
index 7c74c18..70a8029 100644
--- a/boost/serialization/detail/stack_constructor.hpp
+++ b/boost/serialization/detail/stack_constructor.hpp
@@ -7,7 +7,7 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// collections_load_imp.hpp: serialization for loading stl collections
+// stack_constructor.hpp: serialization for loading stl collections
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
diff --git a/boost/serialization/forward_list.hpp b/boost/serialization/forward_list.hpp
index 6efa870..612413b 100644
--- a/boost/serialization/forward_list.hpp
+++ b/boost/serialization/forward_list.hpp
@@ -28,9 +28,14 @@ namespace std{
#endif
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
-#include <boost/serialization/split_free.hpp>
+#include <boost/archive/detail/basic_iarchive.hpp>
+#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
+#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>
+#include <boost/serialization/detail/is_default_constructible.hpp>
namespace boost {
namespace serialization {
@@ -54,30 +59,38 @@ inline void load(
std::forward_list<U, Allocator> &t,
const unsigned int file_version
){
- 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 std::forward_list<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 std::forward_list<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 std::forward_list<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());
+ }
}
}
diff --git a/boost/serialization/hash_collections_load_imp.hpp b/boost/serialization/hash_collections_load_imp.hpp
index de85fd3..88def8f 100644
--- a/boost/serialization/hash_collections_load_imp.hpp
+++ b/boost/serialization/hash_collections_load_imp.hpp
@@ -34,7 +34,6 @@ namespace stl {
template<class Archive, class Container, class InputFunction>
inline void load_hash_collection(Archive & ar, Container &s)
{
- s.clear();
collection_size_type count;
collection_size_type bucket_count;
boost::serialization::item_version_type item_version(0);
@@ -61,6 +60,7 @@ inline void load_hash_collection(Archive & ar, Container &s)
if(boost::archive::library_version_type(3) < library_version){
ar >> BOOST_SERIALIZATION_NVP(item_version);
}
+ s.clear();
#if ! defined(__MWERKS__)
s.resize(bucket_count);
#endif
diff --git a/boost/serialization/list.hpp b/boost/serialization/list.hpp
index 63d3b47..b745d87 100644
--- a/boost/serialization/list.hpp
+++ b/boost/serialization/list.hpp
@@ -21,8 +21,15 @@
#include <boost/config.hpp>
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
+
+#include <boost/archive/detail/basic_iarchive.hpp>
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/nvp.hpp>
+#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>
+#include <boost/serialization/detail/is_default_constructible.hpp>
namespace boost {
namespace serialization {
@@ -45,15 +52,33 @@ inline void load(
std::list<U, Allocator> &t,
const unsigned int /* file_version */
){
- boost::serialization::stl::load_collection<
- Archive,
- std::list<U, Allocator>,
- boost::serialization::stl::archive_input_seq<
- Archive,
- std::list<U, Allocator>
- >,
- boost::serialization::stl::no_reserve_imp<std::list<U, Allocator> >
- >(ar, t);
+ 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);
+ }
+ if(detail::is_default_constructible<U>()){
+ t.resize(count);
+ typename std::list<U, Allocator>::iterator hint;
+ hint = t.begin();
+ while(count-- > 0){
+ ar >> boost::serialization::make_nvp("item", *hint++);
+ }
+ }
+ else{
+ t.clear();
+ while(count-- > 0){
+ detail::stack_construct<Archive, U> u(ar, item_version);
+ ar >> boost::serialization::make_nvp("item", u.reference());
+ t.push_back(u.reference());
+ ar.reset_object_address(& t.back() , & u.reference());
+ }
+ }
}
// split non-intrusive serialization function member into separate
diff --git a/boost/serialization/map.hpp b/boost/serialization/map.hpp
index 11a3d6b..1358d49 100644
--- a/boost/serialization/map.hpp
+++ b/boost/serialization/map.hpp
@@ -10,7 +10,7 @@
// serialization/map.hpp:
// serialization for stl map templates
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// (C) Copyright 2002-2014 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -21,14 +21,51 @@
#include <boost/config.hpp>
+#include <boost/archive/detail/basic_iarchive.hpp>
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/item_version_type.hpp>
+#include <boost/serialization/detail/stack_constructor.hpp>
+
#include <boost/serialization/utility.hpp>
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost {
namespace serialization {
+////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// implementation of serialization for map and mult-map STL containers
+
+template<class Archive, class Container>
+inline void load_map_collection(Archive & ar, Container &s)
+{
+ s.clear();
+ 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);
+ }
+ typename Container::iterator hint;
+ hint = s.begin();
+ while(count-- > 0){
+ typedef typename Container::value_type type;
+ detail::stack_construct<Archive, type> t(ar, item_version);
+ // borland fails silently w/o full namespace
+ ar >> boost::serialization::make_nvp("item", t.reference());
+ typename Container::iterator result = s.insert(hint, t.reference());
+ ar.reset_object_address(& (result->second), & t.reference().second);
+ hint = result;
+ }
+}
+
+// map
template<class Archive, class Type, class Key, class Compare, class Allocator >
inline void save(
Archive & ar,
@@ -47,16 +84,7 @@ inline void load(
std::map<Key, Type, Compare, Allocator> &t,
const unsigned int /* file_version */
){
- boost::serialization::stl::load_collection<
- Archive,
- std::map<Key, Type, Compare, Allocator>,
- boost::serialization::stl::archive_input_map<
- Archive, std::map<Key, Type, Compare, Allocator> >,
- boost::serialization::stl::no_reserve_imp<std::map<
- Key, Type, Compare, Allocator
- >
- >
- >(ar, t);
+ load_map_collection(ar, t);
}
// split non-intrusive serialization function member into separate
@@ -89,16 +117,7 @@ inline void load(
std::multimap<Key, Type, Compare, Allocator> &t,
const unsigned int /* file_version */
){
- boost::serialization::stl::load_collection<
- Archive,
- std::multimap<Key, Type, Compare, Allocator>,
- boost::serialization::stl::archive_input_map<
- Archive, std::multimap<Key, Type, Compare, Allocator>
- >,
- boost::serialization::stl::no_reserve_imp<
- std::multimap<Key, Type, Compare, Allocator>
- >
- >(ar, t);
+ load_map_collection(ar, t);
}
// split non-intrusive serialization function member into separate
diff --git a/boost/serialization/set.hpp b/boost/serialization/set.hpp
index 6882fb0..01289d5 100644
--- a/boost/serialization/set.hpp
+++ b/boost/serialization/set.hpp
@@ -9,7 +9,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// set.hpp: serialization for stl set templates
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// (C) Copyright 2002-2014 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -20,13 +20,46 @@
#include <boost/config.hpp>
+#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>
+
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost {
namespace serialization {
+template<class Archive, class Container>
+inline void load_set_collection(Archive & ar, Container &s)
+{
+ s.clear();
+ 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);
+ }
+ typename Container::iterator hint;
+ hint = s.begin();
+ while(count-- > 0){
+ typedef typename Container::value_type type;
+ detail::stack_construct<Archive, type> t(ar, item_version);
+ // borland fails silently w/o full namespace
+ ar >> boost::serialization::make_nvp("item", t.reference());
+ typename Container::iterator result = s.insert(hint, t.reference());
+ ar.reset_object_address(& (* result), & t.reference());
+ hint = result;
+ }
+}
+
template<class Archive, class Key, class Compare, class Allocator >
inline void save(
Archive & ar,
@@ -44,16 +77,7 @@ inline void load(
std::set<Key, Compare, Allocator> &t,
const unsigned int /* file_version */
){
- boost::serialization::stl::load_collection<
- Archive,
- std::set<Key, Compare, Allocator>,
- boost::serialization::stl::archive_input_set<
- Archive, std::set<Key, Compare, Allocator>
- >,
- boost::serialization::stl::no_reserve_imp<std::set<
- Key, Compare, Allocator>
- >
- >(ar, t);
+ load_set_collection(ar, t);
}
// split non-intrusive serialization function member into separate
@@ -86,16 +110,7 @@ inline void load(
std::multiset<Key, Compare, Allocator> &t,
const unsigned int /* file_version */
){
- boost::serialization::stl::load_collection<
- Archive,
- std::multiset<Key, Compare, Allocator>,
- boost::serialization::stl::archive_input_set<
- Archive, std::multiset<Key, Compare, Allocator>
- >,
- boost::serialization::stl::no_reserve_imp<
- std::multiset<Key, Compare, Allocator>
- >
- >(ar, t);
+ load_set_collection(ar, t);
}
// split non-intrusive serialization function member into separate
diff --git a/boost/serialization/shared_ptr_helper.hpp b/boost/serialization/shared_ptr_helper.hpp
index f4784ec..64269a9 100644
--- a/boost/serialization/shared_ptr_helper.hpp
+++ b/boost/serialization/shared_ptr_helper.hpp
@@ -29,6 +29,7 @@
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/extended_type_info.hpp>
#include <boost/serialization/throw_exception.hpp>
+#include <boost/serialization/type_info_implementation.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/decl.hpp>
diff --git a/boost/serialization/slist.hpp b/boost/serialization/slist.hpp
index 4072076..424aa51 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());
+ }
}
}
diff --git a/boost/serialization/state_saver.hpp b/boost/serialization/state_saver.hpp
index 6e6f985..248b8d9 100644
--- a/boost/serialization/state_saver.hpp
+++ b/boost/serialization/state_saver.hpp
@@ -30,7 +30,7 @@
#include <boost/call_traits.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/has_nothrow_copy.hpp>
-#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/core/no_exceptions_support.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
diff --git a/boost/serialization/string.hpp b/boost/serialization/string.hpp
index d63df76..76e695d 100644
--- a/boost/serialization/string.hpp
+++ b/boost/serialization/string.hpp
@@ -27,65 +27,4 @@ BOOST_CLASS_IMPLEMENTATION(std::string, boost::serialization::primitive_type)
BOOST_CLASS_IMPLEMENTATION(std::wstring, boost::serialization::primitive_type)
#endif
-// left over from a previous incarnation - strings are now always primitive types
-#if 0
-#include <string>
-#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
-#include <boost/serialization/split_free.hpp>
-
-namespace boost {
-namespace serialization {
-
-// basic_string - general case
-template<class Archive, class U, class Allocator>
-inline void save(
- Archive & ar,
- const std::basic_string<U, Allocator> &t,
- const unsigned int file_version
-){
- boost::serialization::stl::save_collection<
- Archive, std::basic_string<U, Allocator>
- >(ar, t);
-}
-
-template<class Archive, class U, class Allocator>
-inline void load(
- Archive & ar,
- std::basic_string<U, Allocator> &t,
- const unsigned int file_version
-){
- boost::serialization::stl::load_collection<
- Archive,
- std::basic_string<U, Allocator>,
- boost::serialization::stl::archive_input_seq<
- Archive,
- std::basic_string<U, Allocator>
- >,
- boost::serialization::stl::reserve_imp<
- std::basic_string<U, Allocator>
- >
- >(ar, t);
-}
-
-// split non-intrusive serialization function member into separate
-// non intrusive save/load member functions
-template<class Archive, class U, class Allocator>
-inline void serialize(
- Archive & ar,
- std::basic_string<U, Allocator> & t,
- const unsigned int file_version
-){
- boost::serialization::split_free(ar, t, file_version);
-}
-
-} // serialization
-} // namespace boost
-
-#include <boost/serialization/collection_traits.hpp>
-
-BOOST_SERIALIZATION_COLLECTION_TRAITS(std::vector)
-
-#endif
-
#endif // BOOST_SERIALIZATION_STRING_HPP
diff --git a/boost/serialization/unordered_collections_load_imp.hpp b/boost/serialization/unordered_collections_load_imp.hpp
index bf56741..48c568d 100644
--- a/boost/serialization/unordered_collections_load_imp.hpp
+++ b/boost/serialization/unordered_collections_load_imp.hpp
@@ -47,7 +47,6 @@ namespace stl {
template<class Archive, class Container, class InputFunction>
inline void load_unordered_collection(Archive & ar, Container &s)
{
- s.clear();
collection_size_type count;
collection_size_type bucket_count;
boost::serialization::item_version_type item_version(0);
@@ -60,6 +59,7 @@ inline void load_unordered_collection(Archive & ar, Container &s)
if(boost::archive::library_version_type(3) < library_version){
ar >> BOOST_SERIALIZATION_NVP(item_version);
}
+ s.clear();
s.rehash(bucket_count);
InputFunction ifunc;
while(count-- > 0){
diff --git a/boost/serialization/vector.hpp b/boost/serialization/vector.hpp
index 3af1d67..aa3aaca 100644
--- a/boost/serialization/vector.hpp
+++ b/boost/serialization/vector.hpp
@@ -21,13 +21,19 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
-#include <boost/type_traits/is_arithmetic.hpp>
+
+#include <boost/archive/detail/basic_iarchive.hpp>
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/item_version_type.hpp>
#include <boost/serialization/collections_save_imp.hpp>
-#include <boost/serialization/collections_load_imp.hpp>
#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/serialization/detail/is_default_constructible.hpp>
#include <boost/mpl/bool.hpp>
// default is being compatible with version 1.34.1 files, not 1.35 files
@@ -70,14 +76,33 @@ inline void load(
const unsigned int /* file_version */,
mpl::false_
){
- boost::serialization::stl::load_collection<
- Archive,
- std::vector<U, Allocator>,
- boost::serialization::stl::archive_input_seq<
- Archive, STD::vector<U, Allocator>
- >,
- boost::serialization::stl::reserve_imp<STD::vector<U, Allocator> >
- >(ar, t);
+ 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);
+ }
+ if(detail::is_default_constructible<U>()){
+ t.resize(count);
+ typename std::vector<U, Allocator>::iterator hint;
+ hint = t.begin();
+ while(count-- > 0){
+ ar >> boost::serialization::make_nvp("item", *hint++);
+ }
+ }
+ else{
+ t.reserve(count);
+ while(count-- > 0){
+ detail::stack_construct<Archive, U> u(ar, item_version);
+ ar >> boost::serialization::make_nvp("item", u.reference());
+ t.push_back(u.reference());
+ ar.reset_object_address(& t.back() , & u.reference());
+ }
+ }
}
// the optimized versions
@@ -186,11 +211,12 @@ inline void load(
// retrieve number of elements
collection_size_type count;
ar >> BOOST_SERIALIZATION_NVP(count);
- t.clear();
- while(count-- > 0){
- bool i;
- ar >> boost::serialization::make_nvp("item", i);
- t.push_back(i);
+ t.resize(count);
+ int i;
+ for(i = 0; i < count; ++i){
+ bool b;
+ ar >> boost::serialization::make_nvp("item", b);
+ t[i] = b;
}
}