1 // Copyright Louis Dionne 2013-2017
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 <utility>
9 namespace hana = boost::hana;
10 
11 
12 struct MoveOnly {
13     int data_;
14     MoveOnly(MoveOnly const&) = delete;
15     MoveOnly& operator=(MoveOnly const&) = delete;
MoveOnlyMoveOnly16     MoveOnly(int data = 1) : data_(data) { }
MoveOnlyMoveOnly17     MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; }
18 
operator =MoveOnly19     MoveOnly& operator=(MoveOnly&& x)
20     { data_ = x.data_; x.data_ = 0; return *this; }
21 
getMoveOnly22     int get() const {return data_;}
operator ==MoveOnly23     bool operator==(const MoveOnly& x) const { return data_ == x.data_; }
operator <MoveOnly24     bool operator< (const MoveOnly& x) const { return data_ <  x.data_; }
25 };
26 
main()27 int main() {
28     {
29         using T = hana::tuple<>;
30         T t0;
31         T t;
32         t = std::move(t0);
33     }
34     {
35         using T = hana::tuple<MoveOnly>;
36         T t0(MoveOnly(0));
37         T t;
38         t = std::move(t0);
39         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0);
40     }
41     {
42         using T = hana::tuple<MoveOnly, MoveOnly>;
43         T t0(MoveOnly(0), MoveOnly(1));
44         T t;
45         t = std::move(t0);
46         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0);
47         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1);
48     }
49     {
50         using T = hana::tuple<MoveOnly, MoveOnly, MoveOnly>;
51         T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
52         T t;
53         t = std::move(t0);
54         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0);
55         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1);
56         BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2);
57     }
58 }
59