3 Forward declares `boost::hana::suffix`.
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_FWD_SUFFIX_HPP
11 #define BOOST_HANA_FWD_SUFFIX_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Inserts a value after each element of a monadic structure.
19 //! @ingroup group-MonadPlus
21 //! Given a monadic structure `xs` and a value `z` (called the suffix),
22 //! `suffix` returns a new monadic structure such that
24 //! suffix(xs, z) == flatten(transform(xs, [](auto x) {
25 //! return concat(lift<M>(x), lift<M>(z));
29 //! For sequences, this simply corresponds to inserting the suffix after
30 //! each element of the sequence. For example, given a sequence
31 //! `[x1, ..., xn]`, `suffix` will return
33 //! [x1, z, x2, z, ..., xn, z]
35 //! As explained above, this can be generalized to other MonadPlus models,
36 //! with various levels of interest.
41 //! Given a MonadPlus `M`, the signature is
42 //! @f$ \mathtt{suffix} : M(T) \times T \to M(T) @f$.
45 //! A monadic structure.
48 //! A value (the suffix) to insert after each element of a monadic
54 //! @include example/suffix.cpp
55 #ifdef BOOST_HANA_DOXYGEN_INVOKED
56 constexpr auto suffix = [](auto&& xs, auto&& sfx) {
57 return tag-dispatched;
60 template <typename M, typename = void>
61 struct suffix_impl : suffix_impl<M, when<true>> { };
64 template <typename Xs, typename Sfx>
65 constexpr auto operator()(Xs&& xs, Sfx&& sfx) const;
68 constexpr suffix_t suffix{};
70 BOOST_HANA_NAMESPACE_END
72 #endif // !BOOST_HANA_FWD_SUFFIX_HPP