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_COPY_HPP
0014 #define RANGES_V3_ALGORITHM_REMOVE_COPY_HPP
0015
0016 #include <meta/meta.hpp>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/algorithm/result_types.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/traits.hpp>
0025 #include <range/v3/range/access.hpp>
0026 #include <range/v3/range/concepts.hpp>
0027 #include <range/v3/range/dangling.hpp>
0028 #include <range/v3/range/traits.hpp>
0029 #include <range/v3/utility/static_const.hpp>
0030
0031 #include <range/v3/detail/prologue.hpp>
0032
0033 namespace ranges
0034 {
0035
0036
0037 template<typename I, typename O>
0038 using remove_copy_result = detail::in_out_result<I, O>;
0039
0040 RANGES_FUNC_BEGIN(remove_copy)
0041
0042
0043 template(typename I, typename S, typename O, typename T, typename P = identity)(
0044 requires input_iterator<I> AND sentinel_for<S, I> AND
0045 weakly_incrementable<O> AND
0046 indirect_relation<equal_to, projected<I, P>, T const *> AND
0047 indirectly_copyable<I, O>)
0048 constexpr remove_copy_result<I, O> RANGES_FUNC(remove_copy)(
0049 I first, S last, O out, T const & val, P proj = P{})
0050 {
0051 for(; first != last; ++first)
0052 {
0053 auto && x = *first;
0054 if(!(invoke(proj, x) == val))
0055 {
0056 *out = (decltype(x) &&)x;
0057 ++out;
0058 }
0059 }
0060 return {first, out};
0061 }
0062
0063
0064 template(typename Rng, typename O, typename T, typename P = identity)(
0065 requires input_range<Rng> AND weakly_incrementable<O> AND
0066 indirect_relation<equal_to, projected<iterator_t<Rng>, P>, T const *> AND
0067 indirectly_copyable<iterator_t<Rng>, O>)
0068 constexpr remove_copy_result<borrowed_iterator_t<Rng>, O>
0069 RANGES_FUNC(remove_copy)(Rng && rng, O out, T const & val, P proj = P{})
0070 {
0071 return (*this)(begin(rng), end(rng), std::move(out), val, std::move(proj));
0072 }
0073
0074 RANGES_FUNC_END(remove_copy)
0075
0076 namespace cpp20
0077 {
0078 using ranges::remove_copy;
0079 using ranges::remove_copy_result;
0080 }
0081
0082 }
0083
0084 #include <range/v3/detail/epilogue.hpp>
0085
0086 #endif