File indexing completed on 2026-05-03 08:13:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_UNIQUE_H
0010 #define _LIBCPP___CXX03___ALGORITHM_UNIQUE_H
0011
0012 #include <__cxx03/__algorithm/adjacent_find.h>
0013 #include <__cxx03/__algorithm/comp.h>
0014 #include <__cxx03/__algorithm/iterator_operations.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__iterator/iterator_traits.h>
0017 #include <__cxx03/__utility/move.h>
0018 #include <__cxx03/__utility/pair.h>
0019
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 #endif
0023
0024 _LIBCPP_PUSH_MACROS
0025 #include <__cxx03/__undef_macros>
0026
0027 _LIBCPP_BEGIN_NAMESPACE_STD
0028
0029
0030
0031 template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
0032 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
0033 __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
0034 __first = std::__adjacent_find(__first, __last, __pred);
0035 if (__first != __last) {
0036
0037
0038 _Iter __i = __first;
0039 for (++__i; ++__i != __last;)
0040 if (!__pred(*__first, *__i))
0041 *++__first = _IterOps<_AlgPolicy>::__iter_move(__i);
0042 ++__first;
0043 return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i));
0044 }
0045 return std::pair<_Iter, _Iter>(__first, __first);
0046 }
0047
0048 template <class _ForwardIterator, class _BinaryPredicate>
0049 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0050 unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
0051 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
0052 }
0053
0054 template <class _ForwardIterator>
0055 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0056 unique(_ForwardIterator __first, _ForwardIterator __last) {
0057 return std::unique(__first, __last, __equal_to());
0058 }
0059
0060 _LIBCPP_END_NAMESPACE_STD
0061
0062 _LIBCPP_POP_MACROS
0063
0064 #endif