summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/map/cnstr.copy.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/test/map/cnstr.copy.cpp
parentInitial commit. (diff)
downloadceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz
ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/test/map/cnstr.copy.cpp')
-rw-r--r--src/boost/libs/hana/test/map/cnstr.copy.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/map/cnstr.copy.cpp b/src/boost/libs/hana/test/map/cnstr.copy.cpp
new file mode 100644
index 000000000..881de02bb
--- /dev/null
+++ b/src/boost/libs/hana/test/map/cnstr.copy.cpp
@@ -0,0 +1,114 @@
+// 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();
+ auto t_implicit = t0;
+ auto t_explicit(t0);
+
+ (void)t_explicit;
+ (void)t_implicit;
+ }
+ {
+ auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>));
+ auto t_implicit = t0;
+ auto t_explicit(t0);
+
+ (void)t_implicit;
+ (void)t_explicit;
+ }
+ {
+ auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>),
+ hana::make_pair(hana::int_c<3>, hana::int_c<30>));
+ auto t_implicit = t0;
+ auto t_explicit(t0);
+
+ (void)t_implicit;
+ (void)t_explicit;
+ }
+ {
+ auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>),
+ hana::make_pair(hana::int_c<3>, hana::int_c<30>),
+ hana::make_pair(hana::type_c<void>, hana::type_c<void*>));
+ auto t_implicit = t0;
+ auto t_explicit(t0);
+
+ (void)t_implicit;
+ (void)t_explicit;
+ }
+ {
+ constexpr auto t0 = hana::make_map(
+ hana::make_pair(hana::int_c<2>, hana::int_c<20>),
+ hana::make_pair(hana::int_c<3>, hana::int_c<30>),
+ hana::make_pair(hana::type_c<void>, hana::type_c<void*>));
+ constexpr auto t_implicit = t0;
+ constexpr auto t_explicit(t0);
+
+ (void)t_implicit;
+ (void)t_explicit;
+ }
+ {
+ auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"}));
+ auto copy = t0;
+ BOOST_HANA_RUNTIME_CHECK(
+ copy == hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"}))
+ );
+ }
+
+ {
+ using Map1 = hana::map<hana::pair<NoCopy, NoCopy>>;
+ Map1 map1; (void)map1;
+ static_assert(!std::is_copy_constructible<Map1>::value, "");
+
+ using Map2 = hana::map<hana::pair<NoCopy_nonempty, NoCopy_nonempty>>;
+ Map2 map2; (void)map2;
+ static_assert(!std::is_copy_constructible<Map2>::value, "");
+ }
+}