]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/at.rv.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / at.rv.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/assert.hpp>
6 #include <boost/hana/tuple.hpp>
7
8 #include <support/tracked.hpp>
9
10 #include <utility>
11 #include <memory>
12 namespace hana = boost::hana;
13
14
15 int main() {
16 {
17 using T = hana::tuple<std::unique_ptr<int>>;
18 T t(std::unique_ptr<int>(new int(3)));
19 std::unique_ptr<int> p = hana::at_c<0>(std::move(t));
20 BOOST_HANA_RUNTIME_CHECK(*p == 3);
21 }
22 // make sure we don't double-move and do other weird stuff
23 {
24 hana::tuple<Tracked, Tracked, Tracked> xs{
25 Tracked{1}, Tracked{2}, Tracked{3}
26 };
27
28 Tracked a = hana::at_c<0>(std::move(xs)); (void)a;
29 Tracked b = hana::at_c<1>(std::move(xs)); (void)b;
30 Tracked c = hana::at_c<2>(std::move(xs)); (void)c;
31 }
32 // test with nested closures
33 {
34 using Inner = hana::tuple<Tracked, Tracked>;
35 hana::tuple<Inner> xs{Inner{Tracked{1}, Tracked{2}}};
36
37 Tracked a = hana::at_c<0>(hana::at_c<0>(std::move(xs))); (void)a;
38 Tracked b = hana::at_c<1>(hana::at_c<0>(std::move(xs))); (void)b;
39 }
40 }