// Copyright Louis Dionne 2013-2016 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include #include namespace hana = boost::hana; // Make sure that the tuple(Yn&&...) is not preferred over the // tuple(tuple const&) and the tuple(tuple&&) // constructors when copy-constructing a tuple with a single // element that can be constructed from tuple const& and // tuple&&, respectively. struct Trap1 { Trap1() = default; Trap1(Trap1 const&) = default; Trap1(Trap1&) = default; Trap1(Trap1&&) = default; template Trap1(X&&) { static_assert(sizeof(X) && false, "this constructor must not be instantiated"); } }; struct Trap2 { Trap2() = default; Trap2(Trap2 const&) = default; Trap2(Trap2&) = default; Trap2(Trap2&&) = default; template Trap2(X) { // not by reference static_assert(sizeof(X) && false, "this constructor must not be instantiated"); } }; int main() { { hana::tuple tuple{}; hana::tuple implicit_copy = tuple; hana::tuple explicit_copy(tuple); hana::tuple implicit_move = std::move(tuple); hana::tuple explicit_move(std::move(tuple)); (void)implicit_copy; (void)explicit_copy; (void)implicit_move; (void)explicit_move; } { hana::tuple tuple{}; hana::tuple implicit_copy = tuple; hana::tuple explicit_copy(tuple); hana::tuple implicit_move = std::move(tuple); hana::tuple explicit_move(std::move(tuple)); (void)implicit_copy; (void)explicit_copy; (void)implicit_move; (void)explicit_move; } }