|
|
|||
File indexing completed on 2025-12-15 09:53:03
0001 /*! 0002 @file 0003 Forward declares `boost::hana::chain`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_CHAIN_HPP 0011 #define BOOST_HANA_FWD_CHAIN_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Feed a monadic value into a monadic computation. 0019 //! @ingroup group-Monad 0020 //! 0021 //! Given a monadic value and a monadic function, `chain` feeds the 0022 //! monadic value into the function, thus performing some Monad-specific 0023 //! effects, and returns the result. An implementation of `chain` must 0024 //! satisfy 0025 //! @code 0026 //! chain(xs, f) == flatten(transform(xs, f)) 0027 //! @endcode 0028 //! 0029 //! 0030 //! Signature 0031 //! --------- 0032 //! For a monad `M`, given a monadic value of type `M(A)` and a monadic 0033 //! function @f$ f : A \to M(B) @f$, `chain` has the signature 0034 //! @f$ 0035 //! \mathtt{chain} : M(A) \times (A \to M(B)) \to M(B) 0036 //! @f$. 0037 //! 0038 //! @param xs 0039 //! A monadic value to be fed to the function `f`. 0040 //! 0041 //! @param f 0042 //! A function taking a normal value in the `xs` structure, and returning 0043 //! a monadic value. This function is called as `f(x)`, where `x` is an 0044 //! element of the structure `xs`. 0045 //! 0046 //! 0047 //! Example 0048 //! ------- 0049 //! @include example/chain.cpp 0050 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0051 constexpr auto chain = [](auto&& xs, auto&& f) -> decltype(auto) { 0052 return tag-dispatched; 0053 }; 0054 #else 0055 template <typename M, typename = void> 0056 struct chain_impl : chain_impl<M, when<true>> { }; 0057 0058 struct chain_t { 0059 template <typename Xs, typename F> 0060 constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; 0061 }; 0062 0063 BOOST_HANA_INLINE_VARIABLE constexpr chain_t chain{}; 0064 #endif 0065 }} // end namespace boost::hana 0066 0067 #endif // !BOOST_HANA_FWD_CHAIN_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|