]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/ext/std/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/ext/std/tuple.hpp>
9 #include <boost/hana/front.hpp>
10 #include <boost/hana/integral_constant.hpp>
14 namespace hana
= boost::hana
;
18 T
const& cref(T
& t
) { return t
; }
20 // a non-movable, non-copyable type
23 RefOnly(RefOnly
const&) = delete;
24 RefOnly(RefOnly
&&) = delete;
28 struct RefOnly_i
: hana::int_
<i
> {
29 RefOnly_i() = default;
30 RefOnly_i(RefOnly_i
const&) = delete;
31 RefOnly_i(RefOnly_i
&&) = delete;
35 std::tuple
<RefOnly
> t
;
37 // Make sure that we return the proper reference types from `at`.
39 RefOnly
&& r1
= hana::at_c
<0>(std::move(t
));
40 RefOnly
& r2
= hana::at_c
<0>(t
);
41 RefOnly
const& r3
= hana::at_c
<0>(cref(t
));
43 (void)r1
; (void)r2
; (void)r3
;
46 // Make sure we return the proper reference types from `front`.
48 RefOnly
&& r1
= hana::front(std::move(t
));
49 RefOnly
& r2
= hana::front(t
);
50 RefOnly
const& r3
= hana::front(cref(t
));
52 (void)r1
; (void)r2
; (void)r3
;
55 // Make sure we return the proper reference types from `back`.
57 RefOnly
&& r1
= hana::back(std::move(t
));
58 RefOnly
& r2
= hana::back(t
);
59 RefOnly
const& r3
= hana::back(cref(t
));
61 (void)r1
; (void)r2
; (void)r3
;
64 // Make sure we return the proper reference types from `at_key`.
66 std::tuple
<RefOnly_i
<3>> t
{};
67 RefOnly_i
<3>& r1
= hana::at_key(t
, RefOnly_i
<3>{});
68 RefOnly_i
<3> const& r2
= hana::at_key(cref(t
), RefOnly_i
<3>{});
69 RefOnly_i
<3>&& r3
= hana::at_key(std::move(t
), RefOnly_i
<3>{});
71 (void)r1
; (void)r2
; (void)r3
;