aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm/ranges_unique.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/__algorithm/ranges_unique.h')
-rw-r--r--libcxx/include/__algorithm/ranges_unique.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/libcxx/include/__algorithm/ranges_unique.h b/libcxx/include/__algorithm/ranges_unique.h
index bdf755e9406e..be427ccf7fad 100644
--- a/libcxx/include/__algorithm/ranges_unique.h
+++ b/libcxx/include/__algorithm/ranges_unique.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/unique.h>
#include <__config>
@@ -25,40 +26,44 @@
#include <__ranges/subrange.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#if _LIBCPP_STD_VER > 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __unique {
-struct __fn {
+ struct __fn {
+ template <
+ permutable _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
- template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
- indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
- _LIBCPP_HIDE_FROM_ABI constexpr
- subrange<_Iter> operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__comp; (void)__proj;
- return {};
- }
-
- template <forward_range _Range, class _Proj = identity,
- indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
- requires permutable<iterator_t<_Range>>
- _LIBCPP_HIDE_FROM_ABI constexpr
- borrowed_subrange_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__comp; (void)__proj;
- return {};
- }
-
-};
+ template <
+ forward_range _Range,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+ };
} // namespace __unique
@@ -69,6 +74,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+#endif // _LIBCPP_STD_VER > 17
#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H