Back to home page

EIC code displayed by LXR

 
 

    


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

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___ALGORITHM_RANGES_PREV_PERMUTATION_H
0010 #define _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
0011 
0012 #include <__algorithm/in_found_result.h>
0013 #include <__algorithm/iterator_operations.h>
0014 #include <__algorithm/make_projected.h>
0015 #include <__algorithm/prev_permutation.h>
0016 #include <__config>
0017 #include <__functional/identity.h>
0018 #include <__functional/ranges_operations.h>
0019 #include <__iterator/concepts.h>
0020 #include <__iterator/sortable.h>
0021 #include <__ranges/access.h>
0022 #include <__ranges/concepts.h>
0023 #include <__ranges/dangling.h>
0024 #include <__utility/move.h>
0025 #include <__utility/pair.h>
0026 
0027 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 #  pragma GCC system_header
0029 #endif
0030 
0031 _LIBCPP_PUSH_MACROS
0032 #include <__undef_macros>
0033 
0034 #if _LIBCPP_STD_VER >= 20
0035 
0036 _LIBCPP_BEGIN_NAMESPACE_STD
0037 
0038 namespace ranges {
0039 
0040 template <class _InIter>
0041 using prev_permutation_result = in_found_result<_InIter>;
0042 
0043 struct __prev_permutation {
0044   template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
0045     requires sortable<_Iter, _Comp, _Proj>
0046   _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>
0047   operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0048     auto __result = std::__prev_permutation<_RangeAlgPolicy>(
0049         std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
0050     return {std::move(__result.first), std::move(__result.second)};
0051   }
0052 
0053   template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
0054     requires sortable<iterator_t<_Range>, _Comp, _Proj>
0055   _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<borrowed_iterator_t<_Range>>
0056   operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
0057     auto __result = std::__prev_permutation<_RangeAlgPolicy>(
0058         ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
0059     return {std::move(__result.first), std::move(__result.second)};
0060   }
0061 };
0062 
0063 inline namespace __cpo {
0064 constexpr inline auto prev_permutation = __prev_permutation{};
0065 } // namespace __cpo
0066 } // namespace ranges
0067 
0068 _LIBCPP_END_NAMESPACE_STD
0069 
0070 #endif // _LIBCPP_STD_VER >= 20
0071 
0072 _LIBCPP_POP_MACROS
0073 
0074 #endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H