]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `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_FWD_REMOVE_IF_HPP | |
11 | #define BOOST_HANA_FWD_REMOVE_IF_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Remove all the elements of a monadic structure that satisfy some | |
19 | //! predicate. | |
20 | //! @ingroup group-MonadPlus | |
21 | //! | |
22 | //! Given a monadic structure `xs` and a unary predicate, `remove_if` | |
23 | //! returns a new monadic structure equal to `xs` without all its elements | |
24 | //! that satisfy the predicate. This is equivalent to `filter` with a | |
25 | //! negated predicate, i.e. | |
26 | //! @code | |
27 | //! remove_if(xs, predicate) == filter(xs, negated predicated) | |
28 | //! @endcode | |
29 | //! | |
30 | //! | |
31 | //! Signature | |
32 | //! --------- | |
33 | //! Given a MonadPlus `M` and a predicate of type \f$ T \to Bool \f$ for | |
34 | //! some compile-time Logical `Bool`, the signature is | |
35 | //! \f$ | |
36 | //! \mathrm{remove\_if} : M(T) \times (T \to Bool) \to M(T) | |
37 | //! \f$ | |
38 | //! | |
39 | //! @param xs | |
40 | //! A monadic structure to remove some elements from. | |
41 | //! | |
42 | //! @param predicate | |
43 | //! A unary predicate called as `predicate(x)`, where `x` is an element | |
44 | //! of the structure, and returning whether `x` should be removed from | |
45 | //! the structure. In the current version of the library, `predicate` | |
46 | //! must return a compile-time Logical. | |
47 | //! | |
48 | //! | |
49 | //! Example | |
50 | //! ------- | |
51 | //! @include example/remove_if.cpp | |
52 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
53 | constexpr auto remove_if = [](auto&& xs, auto&& predicate) { | |
54 | return tag-dispatched; | |
55 | }; | |
56 | #else | |
57 | template <typename M, typename = void> | |
58 | struct remove_if_impl : remove_if_impl<M, when<true>> { }; | |
59 | ||
60 | struct remove_if_t { | |
61 | template <typename Xs, typename Pred> | |
62 | constexpr auto operator()(Xs&& xs, Pred&& pred) const; | |
63 | }; | |
64 | ||
65 | constexpr remove_if_t remove_if{}; | |
66 | #endif | |
67 | BOOST_HANA_NAMESPACE_END | |
68 | ||
69 | #endif // !BOOST_HANA_FWD_REMOVE_IF_HPP |