]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/remove_if.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / remove_if.hpp
1 /*!
2 @file
3 Defines `boost::hana::remove_if`.
4
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)
8 */
9
10 #ifndef BOOST_HANA_REMOVE_IF_HPP
11 #define BOOST_HANA_REMOVE_IF_HPP
12
13 #include <boost/hana/fwd/remove_if.hpp>
14
15 #include <boost/hana/concept/monad_plus.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/dispatch.hpp>
18 #include <boost/hana/filter.hpp>
19 #include <boost/hana/functional/compose.hpp>
20 #include <boost/hana/not.hpp>
21
22
23 BOOST_HANA_NAMESPACE_BEGIN
24 //! @cond
25 template <typename Xs, typename Pred>
26 constexpr auto remove_if_t::operator()(Xs&& xs, Pred&& pred) const {
27 using M = typename hana::tag_of<Xs>::type;
28 using RemoveIf = BOOST_HANA_DISPATCH_IF(remove_if_impl<M>,
29 hana::MonadPlus<M>::value
30 );
31
32 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
33 static_assert(hana::MonadPlus<M>::value,
34 "hana::remove_if(xs, predicate) requires 'xs' to be a MonadPlus");
35 #endif
36
37 return RemoveIf::apply(static_cast<Xs&&>(xs),
38 static_cast<Pred&&>(pred));
39 }
40 //! @endcond
41
42 template <typename M, bool condition>
43 struct remove_if_impl<M, when<condition>> : default_ {
44 template <typename Xs, typename Pred>
45 static constexpr auto apply(Xs&& xs, Pred&& pred) {
46 return hana::filter(static_cast<Xs&&>(xs),
47 hana::compose(hana::not_, static_cast<Pred&&>(pred)));
48 }
49 };
50 BOOST_HANA_NAMESPACE_END
51
52 #endif // !BOOST_HANA_REMOVE_IF_HPP