]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/type_erasure/test/test_member.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / type_erasure / test / test_member.cpp
index 8ab84b83f913617eee03f3c1c808224c6c2b4555..a2ebaafdd6be06eaa46e804cfbe436ea9aad3c60 100644 (file)
@@ -18,7 +18,7 @@
 
 using namespace boost::type_erasure;
 
-BOOST_TYPE_ERASURE_MEMBER((ns)(ns2)(has_fun), fun, 0);
+BOOST_TYPE_ERASURE_MEMBER((ns)(ns2)(has_fun), fun, 0)
 
 struct model {
     explicit model(int v) : val(v) {}
@@ -27,7 +27,7 @@ struct model {
     int val;
 };
 
-BOOST_TYPE_ERASURE_MEMBER((global_has_f1_0), f1, 0);
+BOOST_TYPE_ERASURE_MEMBER((global_has_f1_0), f1, 0)
 
 BOOST_AUTO_TEST_CASE(test_global_has_f1_0) {
     typedef ::boost::mpl::vector<
@@ -38,7 +38,16 @@ BOOST_AUTO_TEST_CASE(test_global_has_f1_0) {
     BOOST_CHECK_EQUAL(x.f1(), 10);
 }
 
-BOOST_TYPE_ERASURE_MEMBER((ns1)(ns2)(ns_has_f1_0), f1, 0);
+BOOST_AUTO_TEST_CASE(test_global_has_f1_0_ref) {
+    typedef ::boost::mpl::vector<
+        global_has_f1_0<int()>,
+        copy_constructible<> > concept_type;
+    model m(10);
+    const any<concept_type, _self&> x(m);
+    BOOST_CHECK_EQUAL(x.f1(), 10);
+}
+
+BOOST_TYPE_ERASURE_MEMBER((ns1)(ns2)(ns_has_f1_0), f1, 0)
 
 BOOST_AUTO_TEST_CASE(test_ns_has_f1_0) {
     typedef ::boost::mpl::vector<
@@ -65,6 +74,24 @@ BOOST_AUTO_TEST_CASE(test_global_has_f1_0_const) {
     BOOST_CHECK_EQUAL(x.f1(), 10);
 }
 
+BOOST_AUTO_TEST_CASE(test_global_has_f1_0_const_ref) {
+    typedef ::boost::mpl::vector<
+        ns1::ns2::ns_has_f1_0<int(), const _self>,
+        copy_constructible<> > concept_type;
+    model_const m(10);
+    const any<concept_type, _self&> x(m);
+    BOOST_CHECK_EQUAL(x.f1(), 10);
+}
+
+BOOST_AUTO_TEST_CASE(test_global_has_f1_0_const_cref) {
+    typedef ::boost::mpl::vector<
+        ns1::ns2::ns_has_f1_0<int(), const _self>,
+        copy_constructible<> > concept_type;
+    model_const m(10);
+    const any<concept_type, const _self&> x(m);
+    BOOST_CHECK_EQUAL(x.f1(), 10);
+}
+
 BOOST_AUTO_TEST_CASE(test_global_has_f1_0_void) {
     typedef ::boost::mpl::vector<
         global_has_f1_0<void()>,
@@ -74,7 +101,7 @@ BOOST_AUTO_TEST_CASE(test_global_has_f1_0_void) {
     x.f1();
 }
 
-BOOST_TYPE_ERASURE_MEMBER((global_has_f1_1), f1, 1);
+BOOST_TYPE_ERASURE_MEMBER((global_has_f1_1), f1, 1)
 
 BOOST_AUTO_TEST_CASE(test_global_has_f1_overload) {
     typedef ::boost::mpl::vector<
@@ -115,6 +142,30 @@ BOOST_AUTO_TEST_CASE(test_global_has_f1_overload_const_non_const) {
     BOOST_CHECK_EQUAL(x2.f1(), 2);
 }
 
+BOOST_AUTO_TEST_CASE(test_global_has_f1_overload_const_non_const_ref) {
+    typedef ::boost::mpl::vector<
+        global_has_f1_0<int(), const _self>, // FIXME: This is order sensitive
+        global_has_f1_0<int(), _self>,
+        copy_constructible<> > concept_type;
+    model_overload_const_non_const m;
+    any<concept_type, _self&> x1(m);
+    BOOST_CHECK_EQUAL(x1.f1(), 1);
+    const any<concept_type, _self&> x2(m);
+    BOOST_CHECK_EQUAL(x2.f1(), 1);
+}
+
+BOOST_AUTO_TEST_CASE(test_global_has_f1_overload_const_non_const_cref) {
+    typedef ::boost::mpl::vector<
+        global_has_f1_0<int(), _self>,
+        global_has_f1_0<int(), const _self>,
+        copy_constructible<> > concept_type;
+    model_overload_const_non_const m;
+    any<concept_type, const _self&> x1(m);
+    BOOST_CHECK_EQUAL(x1.f1(), 2);
+    const any<concept_type, const _self&> x2(m);
+    BOOST_CHECK_EQUAL(x2.f1(), 2);
+}
+
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
 BOOST_AUTO_TEST_CASE(test_global_has_f1_rv) {
@@ -136,3 +187,56 @@ BOOST_AUTO_TEST_CASE(test_global_has_f1_rv_const) {
 }
 
 #endif
+
+
+#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && \
+    !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
+    !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
+    !defined(BOOST_NO_CXX11_DECLTYPE) && \
+    !BOOST_WORKAROUND(BOOST_MSVC, == 1800)
+
+namespace ns3 {
+BOOST_TYPE_ERASURE_MEMBER(f1);
+}
+
+BOOST_AUTO_TEST_CASE(test_simple_member_0) {
+    typedef ::boost::mpl::vector<
+        ns3::has_f1<int()>,
+        copy_constructible<> > concept_type;
+    model m(10);
+    any<concept_type> x(m);
+    BOOST_CHECK_EQUAL(x.f1(), 10);
+}
+
+BOOST_AUTO_TEST_CASE(test_simple_member_1) {
+    typedef ::boost::mpl::vector<
+        ns3::has_f1<int(int)>,
+        copy_constructible<> > concept_type;
+    model m(10);
+    any<concept_type> x(m);
+    BOOST_CHECK_EQUAL(x.f1(5), 15);
+}
+
+namespace ns3 {
+BOOST_TYPE_ERASURE_MEMBER(has_f1_ex, f1);
+}
+
+BOOST_AUTO_TEST_CASE(test_named_member_1) {
+    typedef ::boost::mpl::vector<
+        ns3::has_f1_ex<int(int)>,
+        copy_constructible<> > concept_type;
+    model m(10);
+    any<concept_type> x(m);
+    BOOST_CHECK_EQUAL(x.f1(5), 15);
+}
+
+BOOST_AUTO_TEST_CASE(test_named_member_1_const) {
+    typedef ::boost::mpl::vector<
+        ns3::has_f1_ex<int(int) const>,
+        copy_constructible<> > concept_type;
+    model_const m(10);
+    const any<concept_type> x(m);
+    BOOST_CHECK_EQUAL(x.f1(5), 15);
+}
+
+#endif