diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-25 20:25:30 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-25 20:54:14 +0300 |
commit | 4e197a976205a88dd1de940b253acb2175dc47b8 (patch) | |
tree | a9cfdcc08abde7dd5206d62d23ecadd22b69238b /contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h | |
parent | a2c311b015e4e9366b8da29d07f77cd4b92c1cb0 (diff) | |
download | ydb-4e197a976205a88dd1de940b253acb2175dc47b8.tar.gz |
Upd libc++ to 1 Jun 2022 10c4eec2785a68880c287d36c262d5be3a72a128
[libc++][format] Fixes string-literal formatting.
[libc++] Removes __cpp_lib_monadic_optional.
[libcxx] Temporarily skip Arm configs
[libc++] Reduce the verbosity when running the libc++ Lit configuration
[libc++] Adds __format_string as nasty macro.
[libc++] Use __enable_if_t and is_integral in cstddef
[libc++] Adds missing includes.
[libc++] Minor emscripten changes from downstream
[libc++] Granularize more of <type_traits>
[libc++] Remove unused __functional includes
[libc++] Add various missing _LIBCPP_HIDE_FROM_ABI
[libc++] Use __libcpp_clz for a tighter __log2i function
[libc++] Enable ranges_robust_against* and niebloid tests for implemented ranges algorithms
[libc++] Implement ranges::is_sorted{, _until}
[libc++] Time tests during CI
[libc++] Implement ranges::{all, any, none}_of
[libc++] Remove temporary workaround for existing CMake caches
[libc++] Implement ranges::equal
[libc++] Remove conditional include
[libc++] Use Python subprocess instead of libc++'s own utilities
[libc++] Implement ranges::fill{, _n}
[libc++] Make sure that all headers can be included with modules enabled
[libc++] Rename the generic-singlethreaded CI job to generic-no-threads for consistency
[libc++] Implement ranges::reverse
[libc++] Replace modulus operations in std::seed_seq::generate with conditional checks.
[libc++] type_traits: use __is_core_convertible in __invokable_r.
[libc++] Remove duplicate tests for callable concepts
[libc++] Add ranges::max_element to the synopsis and ADL-proof the __min_element_impl calls
[libc++] Add auto to the list of required extensions in C++03
[libc++] Assume that push_macro and pop_macro are available
[libc++] Always enable the ranges concepts
[libc++] Granularize parts of <type_traits>
[libc++] Improve error messages for disabled modes
[libc++] Override the value of LIBCXX_CXX_ABI in the cache
[libc++] Granularize algorithm benchmarks
[libc++] Enable move semantics for vector in C++03
[libc++][format][5/6] Improve format_to_n.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h new file mode 100644 index 0000000000..e7555d0f9a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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_REVERSE_H +#define _LIBCPP___ALGORITHM_RANGES_REVERSE_H + +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/iter_swap.h> +#include <__iterator/next.h> +#include <__iterator/permutable.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__ranges/dangling.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 { +namespace __reverse { +struct __fn { + + template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent> + requires permutable<_Iter> + _LIBCPP_HIDE_FROM_ABI constexpr + _Iter operator()(_Iter __first, _Sent __last) const { + if constexpr (random_access_iterator<_Iter>) { + if (__first == __last) + return __first; + + auto __end = ranges::next(__first, __last); + auto __ret = __end; + + while (__first < --__end) { + ranges::iter_swap(__first, __end); + ++__first; + } + return __ret; + } else { + auto __end = ranges::next(__first, __last); + auto __ret = __end; + + while (__first != __end) { + if (__first == --__end) + break; + + ranges::iter_swap(__first, __end); + ++__first; + } + return __ret; + } + } + + template <bidirectional_range _Range> + requires permutable<iterator_t<_Range>> + _LIBCPP_HIDE_FROM_ABI constexpr + borrowed_iterator_t<_Range> operator()(_Range&& __range) const { + return (*this)(ranges::begin(__range), ranges::end(__range)); + } + +}; +} // namespace __reverse + +inline namespace __cpo { + inline constexpr auto reverse = __reverse::__fn{}; +} // namespace __cpo +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) + +#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H |