]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::remove`. | |
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_HPP | |
11 | #define BOOST_HANA_FWD_REMOVE_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 are equal to some | |
19 | //! value. | |
20 | //! @ingroup group-MonadPlus | |
21 | //! | |
22 | //! Given a monadic structure `xs` and a `value`, `remove` returns a new | |
23 | //! monadic structure equal to `xs` without all its elements that are | |
24 | //! equal to the given `value`. `remove` is equivalent to `remove_if` | |
25 | //! with the `equal.to(value)` predicate, i.e. | |
26 | //! @code | |
27 | //! remove(xs, value) == remove_if(xs, equal.to(value)) | |
28 | //! @endcode | |
29 | //! | |
30 | //! | |
31 | //! Signature | |
32 | //! --------- | |
33 | //! Given a MonadPlus `M` and a value of type `T`, the signature is | |
34 | //! \f$ | |
35 | //! \mathrm{remove} : M(T) \times T \to M(T) | |
36 | //! \f$ | |
37 | //! | |
38 | //! @param xs | |
39 | //! A monadic structure to remove some elements from. | |
40 | //! | |
41 | //! @param value | |
42 | //! A value that is compared to every element `x` of the structure. | |
43 | //! Elements of the structure that are equal to that value are removed | |
44 | //! from the structure. This requires every element to be Comparable | |
45 | //! with `value`. Furthermore, in the current version of the library, | |
46 | //! comparing `value` with any element of the structure must yield a | |
47 | //! compile-time Logical. | |
48 | //! | |
49 | //! | |
50 | //! Example | |
51 | //! ------- | |
52 | //! @include example/remove.cpp | |
53 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
54 | constexpr auto remove = [](auto&& xs, auto&& value) { | |
55 | return tag-dispatched; | |
56 | }; | |
57 | #else | |
58 | template <typename M, typename = void> | |
59 | struct remove_impl : remove_impl<M, when<true>> { }; | |
60 | ||
61 | struct remove_t { | |
62 | template <typename Xs, typename Value> | |
63 | constexpr auto operator()(Xs&& xs, Value&& value) const; | |
64 | }; | |
65 | ||
66 | constexpr remove_t remove{}; | |
67 | #endif | |
68 | BOOST_HANA_NAMESPACE_END | |
69 | ||
70 | #endif // !BOOST_HANA_FWD_REMOVE_HPP |