Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58485 - in trunk: boost libs/multi_index/doc libs/multi_index/test
From: joaquin_at_[hidden]
Date: 2009-12-22 02:20:42


Author: joaquin
Date: 2009-12-22 02:20:41 EST (Tue, 22 Dec 2009)
New Revision: 58485
URL: http://svn.boost.org/trac/boost/changeset/58485

Log:
handled serialization of non default constructible values
Text files modified:
   trunk/boost/multi_index_container.hpp | 1
   trunk/libs/multi_index/doc/release_notes.html | 17 +++++++++++
   trunk/libs/multi_index/test/test_serialization3.cpp | 57 +++++++++++++++++++++++++++++++++++++++
   3 files changed, 73 insertions(+), 2 deletions(-)

Modified: trunk/boost/multi_index_container.hpp
==============================================================================
--- trunk/boost/multi_index_container.hpp (original)
+++ trunk/boost/multi_index_container.hpp 2009-12-22 02:20:41 EST (Tue, 22 Dec 2009)
@@ -644,6 +644,7 @@
     index_saver_type sm(bfm_allocator::member,s);
 
     for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
+ serialization::save_construct_data_adl(ar,&*it,version);
       ar<<serialization::make_nvp("item",*it);
       sm.add(it.get_node(),ar,version);
     }

Modified: trunk/libs/multi_index/doc/release_notes.html
==============================================================================
--- trunk/libs/multi_index/doc/release_notes.html (original)
+++ trunk/libs/multi_index/doc/release_notes.html 2009-12-22 02:20:41 EST (Tue, 22 Dec 2009)
@@ -31,6 +31,7 @@
 <h2>Contents</h2>
 
 <ul>
+ <li>Boost 1.42 release</li>
   <li>Boost 1.41 release</li>
   <li>Boost 1.38 release</li>
   <li>Boost 1.37 release</li>
@@ -41,6 +42,20 @@
   <li>Boost 1.33 release</li>
 </ul>
 
+<h2><a name="boost_1_42">Boost 1.42 release</a></h2>
+
+<p>
+<ul>
+ <li>
+ <a href="../../serialization/doc/serialization.html#constructors">Serialization
+ of non default constructible values</a> is now properly supported
+ through user-provided facilities <code>save_construct_data</code> and
+ <code>load_construct_data</code>.
+ </li>
+ <li>Maintenance fixes.</li>
+</ul>
+</p>
+
 <h2><a name="boost_1_41">Boost 1.41 release</a></h2>
 <p>
 <ul>
@@ -282,7 +297,7 @@
 
 <br>
 
-<p>Revised September 22nd 2009</p>
+<p>Revised December 22nd 2009</p>
 
 <p>&copy; Copyright 2003-2009 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
 Distributed under the Boost Software

Modified: trunk/libs/multi_index/test/test_serialization3.cpp
==============================================================================
--- trunk/libs/multi_index/test/test_serialization3.cpp (original)
+++ trunk/libs/multi_index/test/test_serialization3.cpp 2009-12-22 02:20:41 EST (Tue, 22 Dec 2009)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for serialization, part 3.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2009 Joaquin M Lopez Munoz.
  * Distributed under 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)
@@ -13,9 +13,49 @@
 
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
+#include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/key_extractors.hpp>
 #include "non_std_allocator.hpp"
 
+struct non_default_ctble
+{
+ non_default_ctble(int n_):n(n_){}
+
+ bool operator==(const non_default_ctble& x)const{return n==x.n;}
+
+ int n;
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+namespace serialization{
+#endif
+
+template<class Archive>
+void save_construct_data(
+ Archive& ar,const non_default_ctble* p,const unsigned int)
+{
+ ar<<boost::serialization::make_nvp("n",p->n);
+}
+
+template<class Archive>
+void load_construct_data(Archive& ar,non_default_ctble* p,const unsigned int)
+{
+ int n=0;
+ ar>>boost::serialization::make_nvp("n",n);
+ ::new(p)non_default_ctble(n);
+}
+
+template<class Archive>
+void serialize(Archive& ar,non_default_ctble& x,const unsigned int)
+{
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace serialization */
+} /* namespace boost*/
+#endif
+
 using namespace boost::multi_index;
 
 void test_serialization3()
@@ -96,4 +136,19 @@
     ia>>it2;
     BOOST_CHECK(it2==hs2.end(buc));
   }
+
+ {
+ typedef multi_index_container<
+ non_default_ctble,
+ indexed_by<
+ ordered_unique<
+ BOOST_MULTI_INDEX_MEMBER(non_default_ctble,int,n)
+ >
+ >
+ > multi_index_t;
+
+ multi_index_t m;
+ for(int i=0;i<100;++i)m.insert(non_default_ctble(i));
+ test_serialization(m);
+ }
 }


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