// 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) #ifndef BOOST_HANA_TEST_LAWS_CONSTANT_HPP #define BOOST_HANA_TEST_LAWS_CONSTANT_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace hana { namespace test { template > struct TestConstant { using T = typename C::value_type; template struct wrap_arbitrary_constant { static constexpr bool value = boost::hana::value(); using hana_tag = detail::CanonicalConstant; }; template TestConstant(Xs xs, Convertibles types) { hana::for_each(xs, [](auto x) { static_assert(Constant{}, ""); }); hana::for_each(xs, hana::capture(types)([](auto types, auto c) { // constexpr-ness of hana::value(c) constexpr auto must_be_constexpr1 = hana::value(c); constexpr auto must_be_constexpr2 = hana::value(); (void)must_be_constexpr1; (void)must_be_constexpr2; // consistency of C::value_type static_assert(std::is_same< T, tag_of_t >{}, ""); // equivalence of value_of(c) and value BOOST_HANA_CHECK(hana::equal( hana::value_of(c), hana::value() )); // equivalence of value() and value(c) BOOST_HANA_CHECK(hana::equal( hana::value(), hana::value(c) )); // conversion from an arbitrary Constant (void)to(wrap_arbitrary_constant{}); static_assert(is_embedded, C>{}, ""); hana::for_each(types, hana::capture(c)([](auto c, auto u) { using U = typename decltype(u)::type; // conversion to something to which the underlying data // type can be converted. BOOST_HANA_CHECK(equal( to(c), make(hana::value(c)) )); static_assert(is_embedded::value ^iff^ is_embedded::value, ""); // common data type static_assert(std::is_same< common_t>, detail::CanonicalConstant> >{}, ""); static_assert(std::is_same< common_t, C>, detail::CanonicalConstant> >{}, ""); static_assert(std::is_same< common_t, common_t >{}, ""); })); })); } }; }}} // end namespace boost::hana::test #endif // !BOOST_HANA_TEST_LAWS_CONSTANT_HPP