]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/map/cnstr.copy.cpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/bool.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/fwd/hash.hpp>
9 #include <boost/hana/integral_constant.hpp>
10 #include <boost/hana/map.hpp>
11 #include <boost/hana/type.hpp>
14 #include <type_traits>
15 namespace hana
= boost::hana
;
20 NoCopy(NoCopy
const&) = delete;
21 friend auto operator==(NoCopy
const&, NoCopy
const&) { return hana::true_c
; }
22 friend auto operator!=(NoCopy
const&, NoCopy
const&) { return hana::false_c
; }
25 // Note: It is also useful to check with a non-empty class, because that
26 // triggers different instantiations due to EBO.
27 struct NoCopy_nonempty
{
28 NoCopy_nonempty() = default;
29 NoCopy_nonempty(NoCopy_nonempty
const&) = delete;
31 friend auto operator==(NoCopy_nonempty
const&, NoCopy_nonempty
const&) { return hana::true_c
; }
32 friend auto operator!=(NoCopy_nonempty
const&, NoCopy_nonempty
const&) { return hana::false_c
; }
35 namespace boost
{ namespace hana
{
37 struct hash_impl
<NoCopy
> {
38 static constexpr auto apply(NoCopy
const&)
39 { return hana::type_c
<NoCopy
>; };
43 struct hash_impl
<NoCopy_nonempty
> {
44 static constexpr auto apply(NoCopy_nonempty
const&)
45 { return hana::type_c
<NoCopy_nonempty
>; };
52 auto t0
= hana::make_map();
60 auto t0
= hana::make_map(hana::make_pair(hana::int_c
<2>, hana::int_c
<20>));
68 auto t0
= hana::make_map(hana::make_pair(hana::int_c
<2>, hana::int_c
<20>),
69 hana::make_pair(hana::int_c
<3>, hana::int_c
<30>));
77 auto t0
= hana::make_map(hana::make_pair(hana::int_c
<2>, hana::int_c
<20>),
78 hana::make_pair(hana::int_c
<3>, hana::int_c
<30>),
79 hana::make_pair(hana::type_c
<void>, hana::type_c
<void*>));
87 constexpr auto t0
= hana::make_map(
88 hana::make_pair(hana::int_c
<2>, hana::int_c
<20>),
89 hana::make_pair(hana::int_c
<3>, hana::int_c
<30>),
90 hana::make_pair(hana::type_c
<void>, hana::type_c
<void*>));
91 constexpr auto t_implicit
= t0
;
92 constexpr auto t_explicit(t0
);
98 auto t0
= hana::make_map(hana::make_pair(hana::int_c
<2>, std::string
{"abcdef"}));
100 BOOST_HANA_RUNTIME_CHECK(
101 copy
== hana::make_map(hana::make_pair(hana::int_c
<2>, std::string
{"abcdef"}))
106 using Map1
= hana::map
<hana::pair
<NoCopy
, NoCopy
>>;
108 static_assert(!std::is_copy_constructible
<Map1
>::value
, "");
110 using Map2
= hana::map
<hana::pair
<NoCopy_nonempty
, NoCopy_nonempty
>>;
112 static_assert(!std::is_copy_constructible
<Map2
>::value
, "");