// 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 #include namespace hana = boost::hana; auto builtin_common_t = hana::sfinae([](auto&& t, auto&& u) -> hana::type< std::decay_t > { return {}; }); template struct common_type { }; template struct common_type : std::conditional_t, T>{} && std::is_same, U>{}, decltype(builtin_common_t(hana::type_c, hana::type_c)), common_type, std::decay_t> > { }; template struct common_type : decltype(hana::monadic_fold_left( hana::tuple_t, hana::type_c>, hana::sfinae(hana::metafunction) )) { }; template using common_type_t = typename common_type::type; BOOST_HANA_CONSTANT_CHECK( builtin_common_t(hana::type_c, hana::type_c) == hana::just(hana::type_c) ); static_assert(std::is_same< common_type_t, int >{}, ""); static_assert(std::is_same< common_type_t, double >{}, ""); static_assert(std::is_same< common_type_t, float >{}, ""); static_assert( hana::sfinae(hana::metafunction)( hana::type_c, hana::type_c, hana::type_c ) == hana::nothing , ""); int main() { }