File indexing completed on 2025-01-18 09:38:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_REMOVE_IF_HPP
0011 #define BOOST_HANA_REMOVE_IF_HPP
0012
0013 #include <boost/hana/fwd/remove_if.hpp>
0014
0015 #include <boost/hana/concept/monad_plus.hpp>
0016 #include <boost/hana/config.hpp>
0017 #include <boost/hana/core/dispatch.hpp>
0018 #include <boost/hana/filter.hpp>
0019 #include <boost/hana/functional/compose.hpp>
0020 #include <boost/hana/not.hpp>
0021
0022
0023 namespace boost { namespace hana {
0024
0025 template <typename Xs, typename Pred>
0026 constexpr auto remove_if_t::operator()(Xs&& xs, Pred&& pred) const {
0027 using M = typename hana::tag_of<Xs>::type;
0028 using RemoveIf = BOOST_HANA_DISPATCH_IF(remove_if_impl<M>,
0029 hana::MonadPlus<M>::value
0030 );
0031
0032 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0033 static_assert(hana::MonadPlus<M>::value,
0034 "hana::remove_if(xs, predicate) requires 'xs' to be a MonadPlus");
0035 #endif
0036
0037 return RemoveIf::apply(static_cast<Xs&&>(xs),
0038 static_cast<Pred&&>(pred));
0039 }
0040
0041
0042 template <typename M, bool condition>
0043 struct remove_if_impl<M, when<condition>> : default_ {
0044 template <typename Xs, typename Pred>
0045 static constexpr auto apply(Xs&& xs, Pred&& pred) {
0046 return hana::filter(static_cast<Xs&&>(xs),
0047 hana::compose(hana::not_, static_cast<Pred&&>(pred)));
0048 }
0049 };
0050 }}
0051
0052 #endif