remove.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. @file
  3. Forward declares `boost::hana::remove`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_REMOVE_HPP
  9. #define BOOST_HANA_FWD_REMOVE_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Remove all the elements of a monadic structure that are equal to some
  14. //! value.
  15. //! @ingroup group-MonadPlus
  16. //!
  17. //! Given a monadic structure `xs` and a `value`, `remove` returns a new
  18. //! monadic structure equal to `xs` without all its elements that are
  19. //! equal to the given `value`. `remove` is equivalent to `remove_if`
  20. //! with the `equal.to(value)` predicate, i.e.
  21. //! @code
  22. //! remove(xs, value) == remove_if(xs, equal.to(value))
  23. //! @endcode
  24. //!
  25. //!
  26. //! Signature
  27. //! ---------
  28. //! Given a MonadPlus `M` and a value of type `T`, the signature is
  29. //! \f$
  30. //! \mathrm{remove} : M(T) \times T \to M(T)
  31. //! \f$
  32. //!
  33. //! @param xs
  34. //! A monadic structure to remove some elements from.
  35. //!
  36. //! @param value
  37. //! A value that is compared to every element `x` of the structure.
  38. //! Elements of the structure that are equal to that value are removed
  39. //! from the structure. This requires every element to be Comparable
  40. //! with `value`. Furthermore, in the current version of the library,
  41. //! comparing `value` with any element of the structure must yield a
  42. //! compile-time Logical.
  43. //!
  44. //!
  45. //! Example
  46. //! -------
  47. //! @include example/remove.cpp
  48. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  49. constexpr auto remove = [](auto&& xs, auto&& value) {
  50. return tag-dispatched;
  51. };
  52. #else
  53. template <typename M, typename = void>
  54. struct remove_impl : remove_impl<M, when<true>> { };
  55. struct remove_t {
  56. template <typename Xs, typename Value>
  57. constexpr auto operator()(Xs&& xs, Value&& value) const;
  58. };
  59. constexpr remove_t remove{};
  60. #endif
  61. BOOST_HANA_NAMESPACE_END
  62. #endif // !BOOST_HANA_FWD_REMOVE_HPP