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/at.hpp> 6 #include <boost/hana/back.hpp> 7 #include <boost/hana/front.hpp> 8 #include <boost/hana/tuple.hpp> 9 10 #include <utility> 11 namespace hana = boost::hana; 12 13 14 // This test checks for move-only friendliness and reference semantics. 15 16 struct MoveOnly { 17 MoveOnly() = default; 18 MoveOnly(MoveOnly&&) = default; 19 MoveOnly& operator=(MoveOnly&&) = default; 20 21 MoveOnly(MoveOnly const&) = delete; 22 MoveOnly& operator=(MoveOnly const&) = delete; 23 }; 24 main()25int main() { 26 { 27 auto xs = hana::make_tuple(MoveOnly{}); 28 auto by_val = [](auto) { }; 29 30 by_val(std::move(xs)); 31 by_val(hana::front(std::move(xs))); 32 by_val(hana::at_c<0>(std::move(xs))); 33 by_val(hana::back(std::move(xs))); 34 } 35 36 { 37 auto const& xs = hana::make_tuple(MoveOnly{}); 38 auto by_const_ref = [](auto const&) { }; 39 40 by_const_ref(xs); 41 by_const_ref(hana::front(xs)); 42 by_const_ref(hana::at_c<0>(xs)); 43 by_const_ref(hana::back(xs)); 44 } 45 46 { 47 auto xs = hana::make_tuple(MoveOnly{}); 48 auto by_ref = [](auto&) { }; 49 50 by_ref(xs); 51 by_ref(hana::front(xs)); 52 by_ref(hana::at_c<0>(xs)); 53 by_ref(hana::back(xs)); 54 } 55 } 56