File indexing completed on 2025-01-18 10:09:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef RANGES_V3_VIEW_REMOVE_HPP
0015 #define RANGES_V3_VIEW_REMOVE_HPP
0016
0017 #include <type_traits>
0018 #include <utility>
0019
0020 #include <meta/meta.hpp>
0021
0022 #include <concepts/concepts.hpp>
0023
0024 #include <range/v3/range_fwd.hpp>
0025
0026 #include <range/v3/functional/bind_back.hpp>
0027 #include <range/v3/functional/comparisons.hpp>
0028 #include <range/v3/view/remove_if.hpp>
0029 #include <range/v3/view/view.hpp>
0030
0031 #include <range/v3/detail/prologue.hpp>
0032
0033 namespace ranges
0034 {
0035
0036
0037 namespace views
0038 {
0039 struct remove_base_fn
0040 {
0041 private:
0042 template<typename Value>
0043 struct pred_
0044 {
0045 Value value_;
0046 template(typename T)(
0047 requires equality_comparable_with<T, Value const &>)
0048 bool operator()(T && other) const
0049 {
0050 return static_cast<T &&>(other) == value_;
0051 }
0052 };
0053
0054 public:
0055 template(typename Rng, typename Value)(
0056 requires move_constructible<Value> AND viewable_range<Rng> AND
0057 input_range<Rng> AND
0058 indirectly_comparable<iterator_t<Rng>, Value const *, equal_to>)
0059 constexpr auto operator()(Rng && rng, Value value) const
0060 {
0061 return remove_if(static_cast<Rng &&>(rng),
0062 pred_<Value>{std::move(value)});
0063 }
0064
0065 template(typename Rng, typename Value, typename Proj)(
0066 requires move_constructible<Value> AND viewable_range<Rng> AND
0067 input_range<Rng> AND
0068 indirectly_comparable<iterator_t<Rng>, Value const *, equal_to, Proj>)
0069 constexpr auto operator()(Rng && rng, Value value, Proj proj) const
0070 {
0071 return remove_if(static_cast<Rng &&>(rng),
0072 pred_<Value>{std::move(value)},
0073 std::move(proj));
0074 }
0075 };
0076
0077 struct remove_bind_fn
0078 {
0079 template<typename Value>
0080 constexpr auto operator()(Value value) const
0081 {
0082 return make_view_closure(bind_back(remove_base_fn{}, std::move(value)));
0083 }
0084 template(typename Value, typename Proj)(
0085 requires (!range<Value>))
0086 constexpr auto operator()(Value && value, Proj proj) const
0087 {
0088 return make_view_closure(bind_back(
0089 remove_base_fn{}, static_cast<Value &&>(value), std::move(proj)));
0090 }
0091 };
0092
0093 struct RANGES_EMPTY_BASES remove_fn
0094 : remove_base_fn, remove_bind_fn
0095 {
0096 using remove_base_fn::operator();
0097 using remove_bind_fn::operator();
0098 };
0099
0100
0101
0102 RANGES_INLINE_VARIABLE(remove_fn, remove)
0103 }
0104
0105 }
0106
0107 #include <range/v3/detail/epilogue.hpp>
0108
0109 #endif