// Copyright Louis Dionne 2013-2017 // 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 #include #include #include #include #include namespace hana = boost::hana; // This test makes sure that we do not instantiate rogue constructors when // doing copies and moves template struct Trap { Trap() = default; Trap(Trap const&) = default; #ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 Trap(Trap&) = default; #endif Trap(Trap&&) = default; template Trap(X&&) { static_assert(hana::detail::wrong{}, "this constructor must not be instantiated"); } }; template constexpr auto operator==(Trap const&, Trap const&) { return hana::bool_c; } template constexpr auto operator!=(Trap const&, Trap const&) { return hana::bool_c; } namespace boost { namespace hana { template struct hash_impl> { static constexpr auto apply(Trap const&) { return hana::type_c>; }; }; }} int main() { { auto expr = hana::make_map( hana::make_pair(Trap<0>{}, Trap<0>{}) ); auto implicit_copy = expr; decltype(expr) explicit_copy(expr); (void)implicit_copy; (void)explicit_copy; } { auto expr = hana::make_map( hana::make_pair(Trap<0>{}, Trap<0>{}) ); auto implicit_move = std::move(expr); decltype(expr) explicit_move(std::move(implicit_move)); (void)implicit_move; (void)explicit_move; } }