/* @copyright Louis Dionne 2015 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 using namespace boost::hana; //! [monadic_fold.left] auto builtin_common_t = sfinae([](auto&& t, auto&& u) -> decltype(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(type, type)), common_type, std::decay_t> > { }; template struct common_type : decltype(monadic_fold.left( tuple_t, type>, sfinae(metafunction) )) { }; template using common_type_t = typename common_type::type; 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( sfinae(metafunction)(type, type, type) == nothing , ""); //! [monadic_fold.left] int main() { }