]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/map/cnstr.move.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/map.hpp>
10 #include <boost/hana/pair.hpp>
11 #include <boost/hana/type.hpp>
13 #include <support/constexpr_move_only.hpp>
14 #include <support/tracked_move_only.hpp>
17 #include <type_traits>
19 namespace hana
= boost::hana
;
22 constexpr bool in_constexpr_context() {
23 auto t0
= hana::make_map(
24 hana::make_pair(ConstexprMoveOnly
<2>{}, ConstexprMoveOnly
<20>{}),
25 hana::make_pair(ConstexprMoveOnly
<3>{}, ConstexprMoveOnly
<30>{}));
26 auto t_implicit
= std::move(t0
);
27 auto t_explicit(std::move(t_implicit
));
34 static_assert(in_constexpr_context(), "");
39 NoMove(NoMove
const&) = delete;
40 NoMove(NoMove
&&) = delete;
41 friend auto operator==(NoMove
const&, NoMove
const&) { return hana::true_c
; }
42 friend auto operator!=(NoMove
const&, NoMove
const&) { return hana::false_c
; }
45 // Note: It is also useful to check with a non-empty class, because that
46 // triggers different instantiations due to EBO.
47 struct NoMove_nonempty
{
48 NoMove_nonempty() = default;
49 NoMove_nonempty(NoMove_nonempty
const&) = delete;
50 NoMove_nonempty(NoMove_nonempty
&&) = delete;
52 friend auto operator==(NoMove_nonempty
const&, NoMove_nonempty
const&) { return hana::true_c
; }
53 friend auto operator!=(NoMove_nonempty
const&, NoMove_nonempty
const&) { return hana::false_c
; }
56 namespace boost
{ namespace hana
{
58 struct hash_impl
<NoMove
> {
59 static constexpr auto apply(NoMove
const&)
60 { return hana::type_c
<NoMove
>; };
64 struct hash_impl
<NoMove_nonempty
> {
65 static constexpr auto apply(NoMove_nonempty
const&)
66 { return hana::type_c
<NoMove_nonempty
>; };
72 auto t0
= hana::make_map();
73 auto t_implicit
= std::move(t0
);
74 auto t_explicit(std::move(t_implicit
));
80 auto t0
= hana::make_map(hana::make_pair(TrackedMoveOnly
<1>{}, TrackedMoveOnly
<10>{}));
81 auto t_implicit
= std::move(t0
);
82 auto t_explicit(std::move(t_implicit
));
88 auto t0
= hana::make_map(hana::make_pair(TrackedMoveOnly
<1>{}, TrackedMoveOnly
<10>{}),
89 hana::make_pair(TrackedMoveOnly
<2>{}, TrackedMoveOnly
<20>{}));
90 auto t_implicit
= std::move(t0
);
91 auto t_explicit(std::move(t_implicit
));
97 auto t0
= hana::make_map(hana::make_pair(TrackedMoveOnly
<1>{}, TrackedMoveOnly
<10>{}),
98 hana::make_pair(TrackedMoveOnly
<2>{}, TrackedMoveOnly
<20>{}),
99 hana::make_pair(TrackedMoveOnly
<3>{}, TrackedMoveOnly
<30>{}));
100 auto t_implicit
= std::move(t0
);
101 auto t_explicit(std::move(t_implicit
));
107 auto t0
= hana::make_map(hana::make_pair(hana::int_c
<2>, std::string
{"abcdef"}));
108 auto moved
= std::move(t0
);
109 BOOST_HANA_RUNTIME_CHECK(
110 moved
== hana::make_map(hana::make_pair(hana::int_c
<2>, std::string
{"abcdef"}))
115 using Map1
= hana::map
<hana::pair
<NoMove
, NoMove
>>;
116 Map1 map1
; (void)map1
;
117 static_assert(!std::is_move_constructible
<Map1
>::value
, "");
119 using Map2
= hana::map
<hana::pair
<NoMove_nonempty
, NoMove_nonempty
>>;
120 Map2 map2
; (void)map2
;
121 static_assert(!std::is_move_constructible
<Map2
>::value
, "");