diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-29 15:12:46 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-08-29 15:12:46 -0700 |
| commit | e6ccc93aacb54f9c183dce43389c2be34e6fde9a (patch) | |
| tree | 797936b1a016fe4fb1a68eac72959c175a8c1a93 /lib/libcxx/include/__algorithm/ranges_prev_permutation.h | |
| parent | b5dc8b67bc2e5dd920a5cabbe32c999f8ea71257 (diff) | |
| download | zig-e6ccc93aacb54f9c183dce43389c2be34e6fde9a.tar.gz zig-e6ccc93aacb54f9c183dce43389c2be34e6fde9a.zip | |
update libcxx to LLVM 15 rc3
Diffstat (limited to 'lib/libcxx/include/__algorithm/ranges_prev_permutation.h')
| -rw-r--r-- | lib/libcxx/include/__algorithm/ranges_prev_permutation.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/libcxx/include/__algorithm/ranges_prev_permutation.h b/lib/libcxx/include/__algorithm/ranges_prev_permutation.h new file mode 100644 index 0000000000..58da606d07 --- /dev/null +++ b/lib/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 |
