|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #ifndef RANGES_V3_ALGORITHM_UNIQUE_HPP
- #define RANGES_V3_ALGORITHM_UNIQUE_HPP
-
- #include <range/v3/range_fwd.hpp>
-
- #include <range/v3/algorithm/adjacent_find.hpp>
- #include <range/v3/functional/comparisons.hpp>
- #include <range/v3/functional/identity.hpp>
- #include <range/v3/functional/invoke.hpp>
- #include <range/v3/iterator/operations.hpp>
- #include <range/v3/range/access.hpp>
- #include <range/v3/range/concepts.hpp>
- #include <range/v3/range/dangling.hpp>
- #include <range/v3/range/traits.hpp>
- #include <range/v3/utility/static_const.hpp>
-
- namespace ranges
- {
-
-
- RANGES_BEGIN_NIEBLOID(unique)
-
-
-
-
-
-
-
-
-
-
- template<typename I, typename S, typename C = equal_to, typename P = identity>
- auto RANGES_FUN_NIEBLOID(unique)(I first, S last, C pred = C{}, P proj = P{})
- ->CPP_ret(I)(
- requires sortable<I, C, P> && sentinel_for<S, I>)
- {
- first = adjacent_find(std::move(first), last, std::ref(pred), std::ref(proj));
-
- if(first != last)
- {
- for(I i = next(first); ++i != last;)
- if(!invoke(pred, invoke(proj, *first), invoke(proj, *i)))
- *++first = iter_move(i);
- ++first;
- }
- return first;
- }
-
-
- template<typename Rng, typename C = equal_to, typename P = identity>
- auto RANGES_FUN_NIEBLOID(unique)(Rng && rng, C pred = C{}, P proj = P{})
- ->CPP_ret(safe_iterator_t<Rng>)(
- requires sortable<iterator_t<Rng>, C, P> && range<Rng>)
- {
- return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
- }
-
- RANGES_END_NIEBLOID(unique)
-
- namespace cpp20
- {
- using ranges::unique;
- }
-
- }
-
- #endif
|