File indexing completed on 2025-01-30 09:43:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_SUFFIX_HPP
0011 #define BOOST_HANA_SUFFIX_HPP
0012
0013 #include <boost/hana/fwd/suffix.hpp>
0014
0015 #include <boost/hana/chain.hpp>
0016 #include <boost/hana/concept/monad_plus.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 #include <boost/hana/functional/partial.hpp>
0020 #include <boost/hana/lift.hpp>
0021 #include <boost/hana/prepend.hpp>
0022
0023
0024 namespace boost { namespace hana {
0025
0026 template <typename Xs, typename Sfx>
0027 constexpr auto suffix_t::operator()(Xs&& xs, Sfx&& sfx) const {
0028 using M = typename hana::tag_of<Xs>::type;
0029 using Suffix = BOOST_HANA_DISPATCH_IF(suffix_impl<M>,
0030 hana::MonadPlus<M>::value
0031 );
0032
0033 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0034 static_assert(hana::MonadPlus<M>::value,
0035 "hana::suffix(xs, sfx) requires 'xs' to be a MonadPlus");
0036 #endif
0037
0038 return Suffix::apply(static_cast<Xs&&>(xs), static_cast<Sfx&&>(sfx));
0039 }
0040
0041
0042 template <typename M, bool condition>
0043 struct suffix_impl<M, when<condition>> : default_ {
0044 template <typename Xs, typename Z>
0045 static constexpr auto apply(Xs&& xs, Z&& z) {
0046 return hana::chain(static_cast<Xs&&>(xs),
0047 hana::partial(hana::prepend, hana::lift<M>(static_cast<Z&&>(z))));
0048 }
0049 };
0050 }}
0051
0052 #endif