File indexing completed on 2025-01-18 10:09:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef RANGES_V3_VIEW_UNIQUE_HPP
0015 #define RANGES_V3_VIEW_UNIQUE_HPP
0016
0017 #include <utility>
0018
0019 #include <meta/meta.hpp>
0020
0021 #include <range/v3/range_fwd.hpp>
0022
0023 #include <range/v3/functional/bind_back.hpp>
0024 #include <range/v3/functional/not_fn.hpp>
0025 #include <range/v3/utility/static_const.hpp>
0026 #include <range/v3/view/adjacent_filter.hpp>
0027 #include <range/v3/view/all.hpp>
0028 #include <range/v3/view/view.hpp>
0029
0030 #include <range/v3/detail/prologue.hpp>
0031
0032 namespace ranges
0033 {
0034
0035
0036 namespace views
0037 {
0038 struct unique_base_fn
0039 {
0040 template(typename Rng, typename C = equal_to)(
0041 requires viewable_range<Rng> AND forward_range<Rng> AND
0042 indirect_relation<C, iterator_t<Rng>>)
0043 constexpr adjacent_filter_view<all_t<Rng>, logical_negate<C>>
0044 operator()(Rng && rng, C pred = {}) const
0045 {
0046 return {all(static_cast<Rng &&>(rng)), not_fn(pred)};
0047 }
0048 };
0049
0050 struct unique_fn : unique_base_fn
0051 {
0052 using unique_base_fn::operator();
0053
0054 template(typename C)(
0055 requires (!range<C>))
0056 constexpr auto operator()(C && pred) const
0057 {
0058 return make_view_closure(
0059 bind_back(unique_base_fn{}, static_cast<C &&>(pred)));
0060 }
0061 };
0062
0063
0064
0065 RANGES_INLINE_VARIABLE(view_closure<unique_fn>, unique)
0066 }
0067
0068 }
0069
0070 #include <range/v3/detail/epilogue.hpp>
0071
0072 #endif