|
|
|||
File indexing completed on 2025-12-15 09:53:05
0001 /*! 0002 @file 0003 Forward declares `boost::hana::remove_if`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_REMOVE_IF_HPP 0011 #define BOOST_HANA_FWD_REMOVE_IF_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Remove all the elements of a monadic structure that satisfy some 0019 //! predicate. 0020 //! @ingroup group-MonadPlus 0021 //! 0022 //! Given a monadic structure `xs` and a unary predicate, `remove_if` 0023 //! returns a new monadic structure equal to `xs` without all its elements 0024 //! that satisfy the predicate. This is equivalent to `filter` with a 0025 //! negated predicate, i.e. 0026 //! @code 0027 //! remove_if(xs, predicate) == filter(xs, negated predicated) 0028 //! @endcode 0029 //! 0030 //! 0031 //! Signature 0032 //! --------- 0033 //! Given a MonadPlus `M` and a predicate of type \f$ T \to Bool \f$ for 0034 //! some compile-time Logical `Bool`, the signature is 0035 //! \f$ 0036 //! \mathrm{remove\_if} : M(T) \times (T \to Bool) \to M(T) 0037 //! \f$ 0038 //! 0039 //! @param xs 0040 //! A monadic structure to remove some elements from. 0041 //! 0042 //! @param predicate 0043 //! A unary predicate called as `predicate(x)`, where `x` is an element 0044 //! of the structure, and returning whether `x` should be removed from 0045 //! the structure. In the current version of the library, `predicate` 0046 //! must return a compile-time Logical. 0047 //! 0048 //! 0049 //! Example 0050 //! ------- 0051 //! @include example/remove_if.cpp 0052 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0053 constexpr auto remove_if = [](auto&& xs, auto&& predicate) { 0054 return tag-dispatched; 0055 }; 0056 #else 0057 template <typename M, typename = void> 0058 struct remove_if_impl : remove_if_impl<M, when<true>> { }; 0059 0060 struct remove_if_t { 0061 template <typename Xs, typename Pred> 0062 constexpr auto operator()(Xs&& xs, Pred&& pred) const; 0063 }; 0064 0065 BOOST_HANA_INLINE_VARIABLE constexpr remove_if_t remove_if{}; 0066 #endif 0067 }} // end namespace boost::hana 0068 0069 #endif // !BOOST_HANA_FWD_REMOVE_IF_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|