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