|
|
|||
File indexing completed on 2025-12-15 09:53:03
0001 /*! 0002 @file 0003 Forward declares `boost::hana::flatten`. 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_FLATTEN_HPP 0011 #define BOOST_HANA_FWD_FLATTEN_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Collapse two levels of monadic structure into a single level. 0019 //! @ingroup group-Monad 0020 //! 0021 //! Given a monadic value wrapped into two levels of monad, `flatten` 0022 //! removes one such level. An implementation of `flatten` must satisfy 0023 //! @code 0024 //! flatten(xs) == chain(xs, id) 0025 //! @endcode 0026 //! 0027 //! For `Sequence`s, this simply takes a `Sequence` of `Sequence`s, and 0028 //! returns a (non-recursively) flattened `Sequence`. 0029 //! 0030 //! 0031 //! Signature 0032 //! --------- 0033 //! For a `Monad` `M`, the signature of `flatten` is 0034 //! @f$ 0035 //! \mathtt{flatten} : M(M(T)) \to M(T) 0036 //! @f$ 0037 //! 0038 //! @param xs 0039 //! A value with two levels of monadic structure, which should be 0040 //! collapsed into a single level of structure. 0041 //! 0042 //! 0043 //! Example 0044 //! ------- 0045 //! @include example/flatten.cpp 0046 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0047 constexpr auto flatten = [](auto&& xs) { 0048 return tag-dispatched; 0049 }; 0050 #else 0051 template <typename M, typename = void> 0052 struct flatten_impl : flatten_impl<M, when<true>> { }; 0053 0054 struct flatten_t { 0055 template <typename Xs> 0056 constexpr auto operator()(Xs&& xs) const; 0057 }; 0058 0059 BOOST_HANA_INLINE_VARIABLE constexpr flatten_t flatten{}; 0060 #endif 0061 }} // end namespace boost::hana 0062 0063 #endif // !BOOST_HANA_FWD_FLATTEN_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|