]>
Commit | Line | Data |
---|---|---|
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/tuple.hpp> | |
6 | ||
7 | #include <utility> | |
8 | namespace hana = boost::hana; | |
9 | ||
10 | ||
11 | // a non-movable, non-copyable type | |
12 | struct RefOnly { | |
13 | RefOnly() = default; | |
14 | RefOnly(RefOnly const&) = delete; | |
15 | RefOnly(RefOnly&&) = delete; | |
16 | }; | |
17 | ||
18 | struct Empty { }; | |
19 | ||
20 | int main() { | |
21 | // Make sure we can create a tuple of rvalue references | |
22 | { | |
23 | RefOnly e{}; | |
24 | hana::tuple<RefOnly&&> xs{std::move(e)}; | |
25 | hana::tuple<RefOnly&&, RefOnly&&> ys{std::move(e), std::move(e)}; | |
26 | (void)xs; (void)ys; | |
27 | ||
28 | hana::tuple<RefOnly&&> xs2 = {std::move(e)}; | |
29 | hana::tuple<RefOnly&&, RefOnly&&> ys2 = {std::move(e), std::move(e)}; | |
30 | (void)xs2; (void)ys2; | |
31 | } | |
32 | ||
33 | // Make sure we can create a tuple of non-const lvalue references | |
34 | { | |
35 | RefOnly e{}; | |
36 | hana::tuple<RefOnly&> xs{e}; | |
37 | hana::tuple<RefOnly&, RefOnly&> ys{e, e}; | |
38 | (void)xs; (void)ys; | |
39 | ||
40 | hana::tuple<RefOnly&> xs2 = {e}; | |
41 | hana::tuple<RefOnly&, RefOnly&> ys2 = {e, e}; | |
42 | (void)xs2; (void)ys2; | |
43 | } | |
44 | ||
45 | // Make sure we can create a tuple of const lvalue references | |
46 | { | |
47 | RefOnly const e{}; | |
48 | hana::tuple<RefOnly const&> xs{e}; | |
49 | hana::tuple<RefOnly const&, RefOnly const&> ys{e, e}; | |
50 | (void)xs; (void)ys; | |
51 | ||
52 | hana::tuple<RefOnly const&> xs2 = {e}; | |
53 | hana::tuple<RefOnly const&, RefOnly const&> ys2 = {e, e}; | |
54 | (void)xs2; (void)ys2; | |
55 | } | |
56 | ||
57 | // Try to construct tuples with mixed references and non-reference members. | |
58 | { | |
59 | RefOnly r{}; | |
60 | Empty e{}; | |
61 | ||
62 | { | |
63 | hana::tuple<RefOnly const&, Empty> xs{r, e}; | |
64 | hana::tuple<RefOnly const&, Empty> ys = {r, e}; | |
65 | (void)xs; (void)ys; | |
66 | } | |
67 | { | |
68 | hana::tuple<RefOnly&, Empty> xs{r, e}; | |
69 | hana::tuple<RefOnly&, Empty> ys = {r, e}; | |
70 | (void)xs; (void)ys; | |
71 | } | |
72 | { | |
73 | hana::tuple<RefOnly&&, Empty> xs{std::move(r), e}; | |
74 | hana::tuple<RefOnly&&, Empty> ys = {std::move(r), e}; | |
75 | (void)xs; (void)ys; | |
76 | } | |
77 | } | |
78 | } |