// 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 mf { struct type { }; }; struct mfc { template struct apply { struct type { }; }; }; template struct tpl { }; // make sure `integral(f)(...)` returns the right type static_assert(std::is_same< decltype(hana::integral(hana::metafunction)()), mf<>::type >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::metafunction)(hana::type_c)), mf::type >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::metafunction)(hana::type_c, hana::type_c)), mf::type >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::template_)()), tpl<> >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::template_)(hana::type_c)), tpl >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::template_)(hana::type_c, hana::type_c)), tpl >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::metafunction_class)()), mfc::apply<>::type >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::metafunction_class)(hana::type_c)), mfc::apply::type >{}, ""); static_assert(std::is_same< decltype(hana::integral(hana::metafunction_class)(hana::type_c, hana::type_c)), mfc::apply::type >{}, ""); // Make sure integral is SFINAE-friendly struct invalid_hana_metafunction { template struct apply { /* missing type alias */ }; }; auto invalid_integral = hana::integral(invalid_hana_metafunction{}); BOOST_HANA_CONSTANT_CHECK(hana::not_( hana::is_valid(invalid_integral)(hana::type_c, hana::type_c) )); int main() { // Make sure we can perform the call; we already made sure the return type was correct constexpr auto a = hana::integral(hana::metafunction)(); (void)a; constexpr auto b = hana::integral(hana::metafunction)(hana::type_c); (void)b; constexpr auto c = hana::integral(hana::metafunction)(hana::type_c, hana::type_c); (void)c; constexpr auto d = hana::integral(hana::metafunction)(hana::type_c, hana::type_c, hana::type_c); (void)d; // Make sure we don't read from a non-constexpr variable auto t = hana::type_c; constexpr auto r = hana::integral(hana::metafunction)(t); (void)r; }