]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/issue_90.cpp
1 // Copyright Louis Dionne 2013-2016
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/at.hpp>
6 #include <boost/hana/at_key.hpp>
7 #include <boost/hana/back.hpp>
8 #include <boost/hana/front.hpp>
9 #include <boost/hana/integral_constant.hpp>
10 #include <boost/hana/tuple.hpp>
13 namespace hana
= boost::hana
;
17 T
const& cref(T
& t
) { return t
; }
19 // a non-movable, non-copyable type
22 RefOnly(RefOnly
const&) = delete;
23 RefOnly(RefOnly
&&) = delete;
27 struct RefOnly_i
: hana::int_
<i
> {
28 RefOnly_i() = default;
29 RefOnly_i(RefOnly_i
const&) = delete;
30 RefOnly_i(RefOnly_i
&&) = delete;
34 hana::tuple
<RefOnly
> t
;
36 // Make sure that we return the proper reference types from `at`.
38 RefOnly
&& r1
= hana::at_c
<0>(std::move(t
));
39 RefOnly
& r2
= hana::at_c
<0>(t
);
40 RefOnly
const& r3
= hana::at_c
<0>(cref(t
));
42 (void)r1
; (void)r2
; (void)r3
;
45 // Make sure we return the proper reference types from `front`.
47 RefOnly
&& r1
= hana::front(std::move(t
));
48 RefOnly
& r2
= hana::front(t
);
49 RefOnly
const& r3
= hana::front(cref(t
));
51 (void)r1
; (void)r2
; (void)r3
;
54 // Make sure we return the proper reference types from `back`.
56 RefOnly
&& r1
= hana::back(std::move(t
));
57 RefOnly
& r2
= hana::back(t
);
58 RefOnly
const& r3
= hana::back(cref(t
));
60 (void)r1
; (void)r2
; (void)r3
;
63 // Make sure we return the proper reference types from `at_key`.
65 hana::tuple
<RefOnly_i
<3>> t
{};
66 RefOnly_i
<3>& r1
= hana::at_key(t
, RefOnly_i
<3>{});
67 RefOnly_i
<3> const& r2
= hana::at_key(cref(t
), RefOnly_i
<3>{});
68 RefOnly_i
<3>&& r3
= hana::at_key(std::move(t
), RefOnly_i
<3>{});
70 (void)r1
; (void)r2
; (void)r3
;