/*! @file Defines `boost::hana::flatten`. Copyright Louis Dionne 2013-2022 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_FLATTEN_HPP #define BOOST_HANA_FLATTEN_HPP #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace hana { //! @cond template constexpr auto flatten_t::operator()(Xs&& xs) const { using M = typename hana::tag_of::type; using Flatten = BOOST_HANA_DISPATCH_IF(flatten_impl, hana::Monad::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Monad::value, "hana::flatten(xs) requires 'xs' to be a Monad"); #endif return Flatten::apply(static_cast(xs)); } //! @endcond template struct flatten_impl> : default_ { template static constexpr auto apply(Xs&& xs) { return hana::chain(static_cast(xs), hana::id); } }; template struct flatten_impl::value>> { template static constexpr auto apply(Xs&& xs) { return detail::unpack_flatten(static_cast(xs), hana::make); } }; }} // end namespace boost::hana #endif // !BOOST_HANA_FLATTEN_HPP