]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/multi_index/test/test_serialization3.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multi_index / test / test_serialization3.cpp
index 6e3c730a78c55212f874dbcea87a53b56c6b495e..5a759c1d592f7449b70d98553e253f403dea593b 100644 (file)
@@ -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 <boost/move/core.hpp>
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
 #include <boost/multi_index/ordered_index.hpp>
@@ -70,6 +71,36 @@ template<> struct version<non_default_ctble>
 } /* 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<x.n;}
+
+  int n;
+
+private:
+  BOOST_MOVABLE_BUT_NOT_COPYABLE(non_copyable)
+};
+
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost{
+namespace serialization{
+#endif
+
+template<class Archive>
+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.emplace(i);
+    test_serialization(m);
+  }
 }