|
|
|||
File indexing completed on 2025-12-15 09:53:03
0001 /*! 0002 @file 0003 Forward declares `boost::hana::append`. 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_APPEND_HPP 0011 #define BOOST_HANA_FWD_APPEND_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Append an element to a monadic structure. 0019 //! @ingroup group-MonadPlus 0020 //! 0021 //! Given an element `x` and a monadic structure `xs`, `append` returns a 0022 //! new monadic structure which is the result of lifting `x` into the 0023 //! monadic structure and then combining that (to the right) with `xs`. 0024 //! In other words, 0025 //! @code 0026 //! append(xs, x) == concat(xs, lift<Xs>(x)) 0027 //! @endcode 0028 //! where `Xs` is the tag of `xs`. For sequences, this has the intuitive 0029 //! behavior of simply appending an element to the end of the sequence, 0030 //! hence the name. 0031 //! 0032 //! > #### Rationale for not calling this `push_back` 0033 //! > See the rationale for using `prepend` instead of `push_front`. 0034 //! 0035 //! 0036 //! Signature 0037 //! --------- 0038 //! Given a MonadPlus `M`, the signature is 0039 //! @f$ \mathtt{append} : M(T) \times T \to M(T) @f$. 0040 //! 0041 //! @param xs 0042 //! A monadic structure that will be combined to the left of the element. 0043 //! 0044 //! @param x 0045 //! An element to combine to the right of the monadic structure. 0046 //! 0047 //! 0048 //! Example 0049 //! ------- 0050 //! @include example/append.cpp 0051 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0052 constexpr auto append = [](auto&& xs, auto&& x) { 0053 return tag-dispatched; 0054 }; 0055 #else 0056 template <typename M, typename = void> 0057 struct append_impl : append_impl<M, when<true>> { }; 0058 0059 struct append_t { 0060 template <typename Xs, typename X> 0061 constexpr auto operator()(Xs&& xs, X&& x) const; 0062 }; 0063 0064 BOOST_HANA_INLINE_VARIABLE constexpr append_t append{}; 0065 #endif 0066 }} // end namespace boost::hana 0067 0068 #endif // !BOOST_HANA_FWD_APPEND_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|