Boost logo

Boost-Commit :

From: ramey_at_[hidden]
Date: 2008-06-10 16:19:01


Author: ramey
Date: 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
New Revision: 46305
URL: http://svn.boost.org/trac/boost/changeset/46305

Log:
fix problem with tracking of std::map items.

Text files modified:
   trunk/boost/serialization/collections_load_imp.hpp | 60 +++++++++++++++++++++++++++++++++++++--
   trunk/boost/serialization/hash_map.hpp | 4 +-
   trunk/boost/serialization/hash_set.hpp | 4 +-
   trunk/boost/serialization/map.hpp | 4 +-
   trunk/boost/serialization/set.hpp | 4 +-
   5 files changed, 64 insertions(+), 12 deletions(-)

Modified: trunk/boost/serialization/collections_load_imp.hpp
==============================================================================
--- trunk/boost/serialization/collections_load_imp.hpp (original)
+++ trunk/boost/serialization/collections_load_imp.hpp 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
@@ -57,9 +57,61 @@
     }
 };
 
-// map and set input
+// map input
 template<class Archive, class Container>
-struct archive_input_unique
+struct archive_input_map
+{
+ inline void operator()(
+ Archive &ar,
+ Container &s,
+ const unsigned int v
+ ){
+ typedef BOOST_DEDUCED_TYPENAME Container::value_type type;
+ detail::stack_construct<Archive, type> t(ar, v);
+ // borland fails silently w/o full namespace
+ ar >> boost::serialization::make_nvp("item", t.reference());
+ std::pair<BOOST_DEDUCED_TYPENAME Container::const_iterator, bool> result =
+ s.insert(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.
+ if(result.second){
+ ar.reset_object_address(
+ & (result.first->second),
+ & t.reference().second
+ );
+ }
+ }
+};
+
+// multimap input
+template<class Archive, class Container>
+struct archive_input_multimap
+{
+ inline void operator()(
+ Archive &ar,
+ Container &s,
+ const unsigned int v
+ ){
+ typedef BOOST_DEDUCED_TYPENAME Container::value_type type;
+ detail::stack_construct<Archive, type> t(ar, v);
+ // borland fails silently w/o full namespace
+ ar >> boost::serialization::make_nvp("item", t.reference());
+ BOOST_DEDUCED_TYPENAME Container::const_iterator result
+ = s.insert(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.
+ ar.reset_object_address(
+ & result->second,
+ & t.reference()
+ );
+ }
+};
+
+// set input
+template<class Archive, class Container>
+struct archive_input_set
 {
     inline void operator()(
         Archive &ar,
@@ -77,9 +129,9 @@
     }
 };
 
-// multiset and multimap input
+// multiset input
 template<class Archive, class Container>
-struct archive_input_multi
+struct archive_input_multiset
 {
     inline void operator()(
         Archive &ar,

Modified: trunk/boost/serialization/hash_map.hpp
==============================================================================
--- trunk/boost/serialization/hash_map.hpp (original)
+++ trunk/boost/serialization/hash_map.hpp 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
@@ -70,7 +70,7 @@
         BOOST_STD_EXTENSION_NAMESPACE::hash_map<
             Key, HashFcn, EqualKey, Allocator
>,
- boost::serialization::stl::archive_input_unique<
+ boost::serialization::stl::archive_input_map<
             Archive,
             BOOST_STD_EXTENSION_NAMESPACE::hash_map<
                 Key, HashFcn, EqualKey, Allocator
@@ -140,7 +140,7 @@
         BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
             Key, HashFcn, EqualKey, Allocator
>,
- boost::serialization::stl::archive_input_multi<
+ boost::serialization::stl::archive_input_multimap<
             Archive,
             BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
                 Key, HashFcn, EqualKey, Allocator

Modified: trunk/boost/serialization/hash_set.hpp
==============================================================================
--- trunk/boost/serialization/hash_set.hpp (original)
+++ trunk/boost/serialization/hash_set.hpp 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
@@ -68,7 +68,7 @@
         BOOST_STD_EXTENSION_NAMESPACE::hash_set<
             Key, HashFcn, EqualKey, Allocator
>,
- boost::serialization::stl::archive_input_unique<
+ boost::serialization::stl::archive_input_set<
             Archive,
             BOOST_STD_EXTENSION_NAMESPACE::hash_set<
                 Key, HashFcn, EqualKey, Allocator
@@ -138,7 +138,7 @@
         BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
             Key, HashFcn, EqualKey, Allocator
>,
- boost::serialization::stl::archive_input_multi<
+ boost::serialization::stl::archive_input_multiset<
             Archive,
             BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
                 Key, HashFcn, EqualKey, Allocator

Modified: trunk/boost/serialization/map.hpp
==============================================================================
--- trunk/boost/serialization/map.hpp (original)
+++ trunk/boost/serialization/map.hpp 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
@@ -50,7 +50,7 @@
     boost::serialization::stl::load_collection<
         Archive,
         std::map<Key, Type, Compare, Allocator>,
- boost::serialization::stl::archive_input_unique<
+ 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
@@ -92,7 +92,7 @@
     boost::serialization::stl::load_collection<
         Archive,
         std::multimap<Key, Type, Compare, Allocator>,
- boost::serialization::stl::archive_input_multi<
+ boost::serialization::stl::archive_input_multimap<
             Archive, std::multimap<Key, Type, Compare, Allocator>
>,
         boost::serialization::stl::no_reserve_imp<

Modified: trunk/boost/serialization/set.hpp
==============================================================================
--- trunk/boost/serialization/set.hpp (original)
+++ trunk/boost/serialization/set.hpp 2008-06-10 16:19:00 EDT (Tue, 10 Jun 2008)
@@ -47,7 +47,7 @@
     boost::serialization::stl::load_collection<
         Archive,
         std::set<Key, Compare, Allocator>,
- boost::serialization::stl::archive_input_unique<
+ boost::serialization::stl::archive_input_set<
             Archive, std::set<Key, Compare, Allocator>
>,
         boost::serialization::stl::no_reserve_imp<std::set<
@@ -89,7 +89,7 @@
     boost::serialization::stl::load_collection<
         Archive,
         std::multiset<Key, Compare, Allocator>,
- boost::serialization::stl::archive_input_multi<
+ boost::serialization::stl::archive_input_multiset<
             Archive, std::multiset<Key, Compare, Allocator>
>,
         boost::serialization::stl::no_reserve_imp<


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk