File indexing completed on 2025-12-16 10:27:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_ALGORITHM_REMOVE_HPP
0014 #define RANGES_V3_ALGORITHM_REMOVE_HPP
0015
0016 #include <meta/meta.hpp>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/algorithm/find.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/iterator/concepts.hpp>
0024 #include <range/v3/iterator/operations.hpp>
0025 #include <range/v3/iterator/traits.hpp>
0026 #include <range/v3/range/access.hpp>
0027 #include <range/v3/range/concepts.hpp>
0028 #include <range/v3/range/dangling.hpp>
0029 #include <range/v3/range/traits.hpp>
0030 #include <range/v3/utility/static_const.hpp>
0031
0032 #include <range/v3/detail/prologue.hpp>
0033
0034 namespace ranges
0035 {
0036
0037
0038 RANGES_FUNC_BEGIN(remove)
0039
0040
0041 template(typename I, typename S, typename T, typename P = identity)(
0042 requires permutable<I> AND sentinel_for<S, I> AND
0043 indirect_relation<equal_to, projected<I, P>, T const *>)
0044 constexpr I RANGES_FUNC(remove)(I first, S last, T const & val, P proj = P{})
0045 {
0046 first = find(std::move(first), last, val, ranges::ref(proj));
0047 if(first != last)
0048 {
0049 for(I i = next(first); i != last; ++i)
0050 {
0051 if(!(invoke(proj, *i) == val))
0052 {
0053 *first = iter_move(i);
0054 ++first;
0055 }
0056 }
0057 }
0058 return first;
0059 }
0060
0061
0062 template(typename Rng, typename T, typename P = identity)(
0063 requires forward_range<Rng> AND permutable<iterator_t<Rng>> AND
0064 indirect_relation<equal_to, projected<iterator_t<Rng>, P>, T const *>)
0065 constexpr borrowed_iterator_t<Rng>
0066 RANGES_FUNC(remove)(Rng && rng, T const & val, P proj = P{})
0067 {
0068 return (*this)(begin(rng), end(rng), val, std::move(proj));
0069 }
0070
0071 RANGES_FUNC_END(remove)
0072
0073 namespace cpp20
0074 {
0075 using ranges::remove;
0076 }
0077
0078 }
0079
0080 #include <range/v3/detail/epilogue.hpp>
0081
0082 #endif