]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/type_erasure/test/test_construct.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / type_erasure / test / test_construct.cpp
index 8b352b145a510e83f0455b7f87db6331fd246d15..7836b9216ba7da1dde91f7753ac31b080c237df9 100644 (file)
@@ -102,6 +102,10 @@ std::vector<T> make_vector(T t0, T t1) {
     return result;
 }
 
+#ifdef BOOST_MSVC
+#pragma warning(disable:4521) // multiple copy constructors specified
+#endif
+
 struct test_class
 {
 
@@ -181,30 +185,50 @@ struct make_arg_impl<binding<Concept> >
 };
 
 template<class Concept>
-struct make_arg_impl<any<Concept, _a> >
+struct make_arg_impl<any<Concept, _a>&>
 {
-    static any<Concept, _a> apply()
+    static any<Concept, _a>& apply()
     {
-        return any<Concept, _a>(
+        static any<Concept, _a> result(
             test_class(),
             make_binding< ::boost::mpl::map<
                 ::boost::mpl::pair<_a, test_class>,
                 ::boost::mpl::pair<_b, int>
         > >());
+        return result;
     }
 };
 
 template<class Concept>
-struct make_arg_impl<any<Concept, _b> >
+struct make_arg_impl<any<Concept, _b>&>
 {
-    static any<Concept, _b> apply()
+    static any<Concept, _b>& apply()
     {
-        return any<Concept, _b>(
+        static any<Concept, _b> result(
             (int)id_int,
             make_binding< ::boost::mpl::map<
                 ::boost::mpl::pair<_a, test_class>,
                 ::boost::mpl::pair<_b, int>
         > >());
+        return result;
+    }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _a> >
+{
+    static any<Concept, _a> apply()
+    {
+        return make_arg_impl<any<Concept, _a>&>::apply();
+    }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _b> >
+{
+    static any<Concept, _b> apply()
+    {
+        return make_arg_impl<any<Concept, _b>&>::apply();
     }
 };
 
@@ -251,6 +275,14 @@ struct make_arg_impl<T&>
         return result;
     }
 };
+template<class T>
+struct make_arg_impl<const T&>
+{
+    static T& apply()
+    {
+        return make_arg_impl<T&>::apply();
+    }
+};
 
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
@@ -259,8 +291,7 @@ struct make_arg_impl<T&&>
 {
     static T&& apply()
     {
-        static T result = make_arg_impl<T>::apply();
-        return std::move(result);
+        return std::move(make_arg_impl<T&>::apply());
     }
 };
 
@@ -324,12 +355,22 @@ struct tester<Concept, void(T0, T1, T2)>
     }
 };
 
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+// We need copy_constructible in order to get an rvalue.
+#define CONSTRUCT_COMMON(p) common<p>
+#else
+// Don't include the copy constructor if we don't
+// need it, as it can hide the non-const copy constructor.
+#define CONSTRUCT_COMMON(p) destructible<p>, typeid_<p>
+#endif
+
 #define TEST_CONSTRUCT(sig, args, expected_) \
 {\
     typedef ::boost::mpl::vector<\
-        common<_a>, \
+        CONSTRUCT_COMMON(_a), \
         common<_b>,\
-        constructible<sig>\
+        constructible<sig>,\
+        extra\
     > C;\
     std::vector<int> result = tester<C, void args>::apply();\
     std::vector<int> expected = make_vector expected_;\
@@ -337,7 +378,12 @@ struct tester<Concept, void(T0, T1, T2)>
         expected.begin(), expected.end());\
 }
 
-BOOST_AUTO_TEST_CASE(test_default)
+typedef ::boost::mpl::vector<
+    ::boost::mpl::vector<>,
+    ::boost::type_erasure::relaxed
+> maybe_relaxed;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_default, extra, maybe_relaxed)
 {
     TEST_CONSTRUCT(_a(), (binding<C>), ());
     TEST_CONSTRUCT(_a(), (binding<C>&), ());
@@ -345,7 +391,7 @@ BOOST_AUTO_TEST_CASE(test_default)
 }
 
 // test all forms of direct construction that take 1 argument
-BOOST_AUTO_TEST_CASE(test_construct1)
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_construct1, extra, maybe_relaxed)
 {
     // construction from int
     TEST_CONSTRUCT(_a(int&), (binding<C>, int&), (lvalue | id_int));
@@ -380,7 +426,7 @@ BOOST_AUTO_TEST_CASE(test_construct1)
 
     // Test same any type
 
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
     // ambiguous with the copy constructor in C++03
     TEST_CONSTRUCT(_a(_a&), (any<C, _a>&), (lvalue | id_copy));
     TEST_CONSTRUCT(_a(_a&), (binding<C>, any<C, _a>&), (lvalue | id_copy));
@@ -401,7 +447,7 @@ BOOST_AUTO_TEST_CASE(test_construct1)
     TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, any<C, _a>&), (const_lvalue | id_copy));
     TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, const any<C, _a>&), (const_lvalue | id_copy));
     
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
 
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
     TEST_CONSTRUCT(_a(_a&&), (any<C, _a>), (rvalue | id_copy));
@@ -444,7 +490,7 @@ BOOST_AUTO_TEST_CASE(test_construct1)
     TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b>&), (rvalue | id_int));
     TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, _b>&), (rvalue | id_int));
     
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
 
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
     TEST_CONSTRUCT(_a(_b&&), (any<C, _b>), (rvalue | id_int));
@@ -569,7 +615,7 @@ BOOST_AUTO_TEST_CASE(test_construct1)
 }
 
 // test constructors with 2 parameters
-BOOST_AUTO_TEST_CASE(test_construct2)
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_construct2, extra, maybe_relaxed)
 {
     TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int), (rvalue | id_int, rvalue | id_int));
     TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int&), (rvalue | id_int, rvalue | id_int));