Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:21

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_UNIQUE_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_UNIQUE_H
0011 
0012 #include <__cxx03/__algorithm/iterator_operations.h>
0013 #include <__cxx03/__algorithm/make_projected.h>
0014 #include <__cxx03/__algorithm/unique.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__functional/identity.h>
0017 #include <__cxx03/__functional/invoke.h>
0018 #include <__cxx03/__functional/ranges_operations.h>
0019 #include <__cxx03/__iterator/concepts.h>
0020 #include <__cxx03/__iterator/iterator_traits.h>
0021 #include <__cxx03/__iterator/permutable.h>
0022 #include <__cxx03/__iterator/projected.h>
0023 #include <__cxx03/__ranges/access.h>
0024 #include <__cxx03/__ranges/concepts.h>
0025 #include <__cxx03/__ranges/dangling.h>
0026 #include <__cxx03/__ranges/subrange.h>
0027 #include <__cxx03/__utility/forward.h>
0028 #include <__cxx03/__utility/move.h>
0029 #include <__cxx03/__utility/pair.h>
0030 
0031 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0032 #  pragma GCC system_header
0033 #endif
0034 
0035 _LIBCPP_PUSH_MACROS
0036 #include <__cxx03/__undef_macros>
0037 
0038 #if _LIBCPP_STD_VER >= 20
0039 
0040 _LIBCPP_BEGIN_NAMESPACE_STD
0041 
0042 namespace ranges {
0043 namespace __unique {
0044 
0045 struct __fn {
0046   template <permutable _Iter,
0047             sentinel_for<_Iter> _Sent,
0048             class _Proj                                                  = identity,
0049             indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
0050   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
0051   operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0052     auto __ret =
0053         std::__unique<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
0054     return {std::move(__ret.first), std::move(__ret.second)};
0055   }
0056 
0057   template <forward_range _Range,
0058             class _Proj                                                               = identity,
0059             indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
0060     requires permutable<iterator_t<_Range>>
0061   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
0062   operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
0063     auto __ret = std::__unique<_RangeAlgPolicy>(
0064         ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
0065     return {std::move(__ret.first), std::move(__ret.second)};
0066   }
0067 };
0068 
0069 } // namespace __unique
0070 
0071 inline namespace __cpo {
0072 inline constexpr auto unique = __unique::__fn{};
0073 } // namespace __cpo
0074 } // namespace ranges
0075 
0076 _LIBCPP_END_NAMESPACE_STD
0077 
0078 #endif // _LIBCPP_STD_VER >= 20
0079 
0080 _LIBCPP_POP_MACROS
0081 
0082 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_UNIQUE_H