]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/pair/issue_90.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / pair / 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)
4
5 #include <boost/hana/first.hpp>
6 #include <boost/hana/pair.hpp>
7 #include <boost/hana/second.hpp>
8
9 #include <utility>
10 namespace hana = boost::hana;
11
12
13 template <typename T>
14 T const& cref(T& t) { return t; }
15
16 // a non-movable, non-copyable type
17 struct RefOnly {
18 RefOnly() = default;
19 RefOnly(RefOnly const&) = delete;
20 RefOnly(RefOnly&&) = delete;
21 };
22
23 int main() {
24 // This test makes sure that we return the proper reference types from
25 // `first` and `second`.
26 hana::pair<RefOnly, RefOnly> p;
27
28 {
29 RefOnly&& r1 = hana::first(std::move(p));
30 RefOnly& r2 = hana::first(p);
31 RefOnly const& r3 = hana::first(cref(p));
32
33 (void)r1; (void)r2; (void)r3;
34 }
35
36 {
37 RefOnly&& r1 = hana::second(std::move(p));
38 RefOnly& r2 = hana::second(p);
39 RefOnly const& r3 = hana::second(cref(p));
40
41 (void)r1; (void)r2; (void)r3;
42 }
43 }