aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-08-13 15:37:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:04:56 +0000
commit61cfbce3347e4372143bcabf7b197577b9f3958a (patch)
treea996b7140fcecf4ec110b2ac28983b858e5df637 /contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
parent972a253a57b6f144b0e4a3e2080a2a0076ec55a0 (diff)
parent677727e8296a802385345db6fa65e68223f4597a (diff)
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h')
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
new file mode 100644
index 000000000000..58da606d07f7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
+
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/prev_permutation.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.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)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter>
+using prev_permutation_result = in_found_result<_InIter>;
+
+namespace __prev_permutation {
+
+struct __fn {
+
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <bidirectional_range _Range,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<borrowed_iterator_t<_Range>>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+};
+
+} // namespace __prev_permutation
+
+inline namespace __cpo {
+constexpr inline auto prev_permutation = __prev_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H