]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/hana/test/map/cnstr.copy.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / map / cnstr.copy.cpp
index 002a3a8b25e5cccb36417c033e3cc6d0e061e4f8..6bf6160777736c26349c7ad578b7160a0ceb5f3d 100644 (file)
@@ -1,17 +1,52 @@
-// Copyright Louis Dionne 2013-2016
+// Copyright Louis Dionne 2013-2017
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
 
 #include <boost/hana/assert.hpp>
+#include <boost/hana/bool.hpp>
 #include <boost/hana/equal.hpp>
+#include <boost/hana/fwd/hash.hpp>
 #include <boost/hana/integral_constant.hpp>
 #include <boost/hana/map.hpp>
 #include <boost/hana/type.hpp>
 
 #include <string>
+#include <type_traits>
 namespace hana = boost::hana;
 
 
+struct NoCopy {
+    NoCopy() = default;
+    NoCopy(NoCopy const&) = delete;
+    friend auto operator==(NoCopy const&, NoCopy const&) { return hana::true_c; }
+    friend auto operator!=(NoCopy const&, NoCopy const&) { return hana::false_c; }
+};
+
+// Note: It is also useful to check with a non-empty class, because that
+//       triggers different instantiations due to EBO.
+struct NoCopy_nonempty {
+    NoCopy_nonempty() = default;
+    NoCopy_nonempty(NoCopy_nonempty const&) = delete;
+    int i;
+    friend auto operator==(NoCopy_nonempty const&, NoCopy_nonempty const&) { return hana::true_c; }
+    friend auto operator!=(NoCopy_nonempty const&, NoCopy_nonempty const&) { return hana::false_c; }
+};
+
+namespace boost { namespace hana {
+    template <>
+    struct hash_impl<NoCopy> {
+        static constexpr auto apply(NoCopy const&)
+        { return hana::type_c<NoCopy>; };
+    };
+
+    template <>
+    struct hash_impl<NoCopy_nonempty> {
+        static constexpr auto apply(NoCopy_nonempty const&)
+        { return hana::type_c<NoCopy_nonempty>; };
+    };
+}}
+
+
 int main() {
     {
         auto t0 = hana::make_map();
@@ -66,4 +101,14 @@ int main() {
             copy == hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"}))
         );
     }
+
+    {
+        using Map1 = hana::map<hana::pair<NoCopy, NoCopy>>;
+        Map1 map1;
+        static_assert(!std::is_copy_constructible<Map1>::value, "");
+
+        using Map2 = hana::map<hana::pair<NoCopy_nonempty, NoCopy_nonempty>>;
+        Map2 map2;
+        static_assert(!std::is_copy_constructible<Map2>::value, "");
+    }
 }