// 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 namespace hana = boost::hana; struct x1; struct x2; struct x3; struct y1 { }; struct y2 { }; struct y3 { }; template struct f { struct type; }; template constexpr auto valid_call(F f, T ...t) -> decltype(((void)f(t...)), true) { return true; } constexpr auto valid_call(...) { return false; } BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::metafunction(), hana::type_c::type> )); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::metafunction(hana::type_c), hana::type_c::type> )); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::metafunction(hana::type_c, hana::type_c), hana::type_c::type> )); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::metafunction(hana::type_c, hana::type_c, hana::type_c), hana::type_c::type> )); using F = decltype(hana::metafunction); static_assert(std::is_same, f<>>::value, ""); static_assert(std::is_same, f>::value, ""); static_assert(std::is_same, f>::value, ""); static_assert(std::is_same, f>::value, ""); // Make sure we're SFINAE-friendly template struct no_type { }; static_assert(!valid_call(hana::metafunction), ""); static_assert(!valid_call(hana::metafunction, hana::type_c), ""); // Make sure we model the Metafunction concept static_assert(hana::Metafunction)>::value, ""); static_assert(hana::Metafunction)&>::value, ""); // Make sure metafunction is SFINAE-friendly template struct not_a_metafunction { }; BOOST_HANA_CONSTANT_CHECK(hana::not_( hana::is_valid(hana::metafunction)(hana::type_c) )); // Make sure we don't read from a non-constexpr variable int main() { auto t = hana::type_c; constexpr auto r = hana::metafunction(t); (void)r; }