From 4d21e8962151d7d6852c5bc861a2f09fed060be5 Mon Sep 17 00:00:00 2001
From: joaquintides
Date: Tue, 13 Mar 2018 22:05:01 +0100
Subject: [PATCH] addressed https://svn.boost.org/trac10/ticket/13478
---
doc/release_notes.html | 14 ++++++-
include/boost/multi_index_container.hpp | 2 +-
test/test_serialization3.cpp | 50 ++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/doc/release_notes.html b/doc/release_notes.html
index b07f2dd..e1818f1 100644
--- a/doc/release_notes.html
+++ b/doc/release_notes.html
@@ -30,6 +30,7 @@ Acknowledgements
Contents
+
+
+
+
+ - Containers of moveable but non-copyable elements can now be serialized
+ (ticket #13478).
+ Thanks to Sébastien Paris for the report.
+
+
+
+
@@ -572,7 +584,7 @@ Acknowledgements
-
Revised January 3rd 2018
+Revised March 13th 2018
© Copyright 2003-2018 Joaquín M López Muñoz.
Distributed under the Boost Software
diff --git a/include/boost/multi_index_container.hpp b/include/boost/multi_index_container.hpp
index f0190d5..8843517 100644
--- a/include/boost/multi_index_container.hpp
+++ b/include/boost/multi_index_container.hpp
@@ -960,7 +960,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
for(std::size_t n=0;n value("item",ar,value_version);
- std::pair p=insert_(
+ std::pair p=insert_rv_(
value.get(),super::end().get_node());
if(!p.second)throw_exception(
archive::archive_exception(
diff --git a/test/test_serialization3.cpp b/test/test_serialization3.cpp
index 6e3c730..f6d2549 100644
--- a/test/test_serialization3.cpp
+++ b/test/test_serialization3.cpp
@@ -1,6 +1,6 @@
/* Boost.MultiIndex test for serialization, part 3.
*
- * Copyright 2003-2013 Joaquin M Lopez Munoz.
+ * Copyright 2003-2018 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)
@@ -11,6 +11,7 @@
#include "test_serialization3.hpp"
#include "test_serialization_template.hpp"
+#include
#include
#include
#include
@@ -70,6 +71,36 @@ template<> struct version
} /* namespace serialization */
} /* namespace boost*/
+struct non_copyable
+{
+ non_copyable(int n_=0):n(n_){}
+ non_copyable(BOOST_RV_REF(non_copyable) x):n(x.n){}
+
+ bool operator==(const non_copyable& x)const{return n==x.n;}
+ bool operator<(const non_copyable& x)const{return n
+void serialize(Archive& ar,non_copyable& x,const unsigned int)
+{
+ ar&boost::serialization::make_nvp("n",x.n);
+}
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+} /* namespace serialization */
+} /* namespace boost*/
+#endif
+
using namespace boost::multi_index;
void test_serialization3()
@@ -165,4 +196,21 @@ void test_serialization3()
for(int i=0;i<100;++i)m.insert(non_default_ctble(i));
test_serialization(m);
}
+
+ {
+ /* testcase for https://svn.boost.org/trac10/ticket/13478 */
+
+ typedef multi_index_container<
+ non_copyable,
+ indexed_by<
+ ordered_unique<
+ BOOST_MULTI_INDEX_MEMBER(non_copyable,int,n)
+ >
+ >
+ > multi_index_t;
+
+ multi_index_t m;
+ for(int i=0;i<100;++i)m.insert(non_copyable(i));
+ test_serialization(m);
+ }
}