// 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 #include #include namespace hana = boost::hana; struct NoDefault { NoDefault() = delete; explicit constexpr NoDefault(int) { } }; struct DefaultOnly { DefaultOnly() = default; DefaultOnly(DefaultOnly const&) = delete; DefaultOnly(DefaultOnly&&) = delete; }; struct NonConstexprDefault { NonConstexprDefault() { } }; int main() { { hana::pair p; BOOST_HANA_RUNTIME_CHECK(hana::first(p) == 0.0f); BOOST_HANA_RUNTIME_CHECK(hana::second(p) == nullptr); } // make sure it also works constexpr { constexpr hana::pair p; static_assert(hana::first(p) == 0.0f, ""); static_assert(hana::second(p) == nullptr, ""); } // make sure the default constructor is not instantiated when the // members of the pair are not default-constructible { hana::pair p{NoDefault{1}, NoDefault{2}}; (void)p; } // make sure it works when only the default constructor is defined { hana::pair p; (void)p; } { hana::pair p; (void)p; } }