/*! @file Defines `boost::hana::chain`. @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) */ #ifndef BOOST_HANA_CHAIN_HPP #define BOOST_HANA_CHAIN_HPP #include #include #include #include #include #include namespace boost { namespace hana { //! @cond template constexpr decltype(auto) chain_t::operator()(Xs&& xs, F&& f) const { using M = typename hana::tag_of::type; using Chain = BOOST_HANA_DISPATCH_IF(chain_impl, hana::Monad::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Monad::value, "hana::chain(xs, f) requires 'xs' to be a Monad"); #endif return Chain::apply(static_cast(xs), static_cast(f)); } //! @endcond template struct chain_impl> : default_ { template static constexpr auto apply(Xs&& xs, F&& f) { return hana::flatten(hana::transform(static_cast(xs), static_cast(f))); } }; }} // end namespace boost::hana #endif // !BOOST_HANA_CHAIN_HPP