aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
diff options
context:
space:
mode:
authorhiddenpath <hiddenpath@yandex-team.com>2024-02-21 23:16:42 +0300
committerhiddenpath <hiddenpath@yandex-team.com>2024-02-21 23:33:25 +0300
commit9052eb5cc304b8da8885fc4e3364ebddc16945f3 (patch)
tree3c252f6161dd0745c7732d74c9304c000645ab47 /contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
parentf5eb715f103692e7c7536e13bef3f281fd78e5e7 (diff)
downloadydb-9052eb5cc304b8da8885fc4e3364ebddc16945f3.tar.gz
Update libcxx to llvmorg-17.0.6
Update libcxx to llvmorg-17.0.6 c871ef572c71b4fef22d4a9e65bcebc57e625aea
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
index 580c2a14c9..de870e3811 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
@@ -9,7 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_H
#define _LIBCPP___ALGORITHM_RANGES_FIND_H
+#include <__algorithm/find.h>
#include <__algorithm/ranges_find_if.h>
+#include <__algorithm/unwrap_range.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
@@ -26,38 +28,48 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17
+#if _LIBCPP_STD_VER >= 20
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __find {
struct __fn {
+ template <class _Iter, class _Sent, class _Tp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr _Iter
+ __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
+ if constexpr (forward_iterator<_Iter>) {
+ auto [__first_un, __last_un] = std::__unwrap_range(__first, std::move(__last));
+ return std::__rewrap_range<_Sent>(
+ std::move(__first), std::__find_impl(std::move(__first_un), std::move(__last_un), __value, __proj));
+ } else {
+ return std::__find_impl(std::move(__first), std::move(__last), __value, __proj);
+ }
+ }
+
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
- _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
- _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
- return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
+ operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
+ return __find_unwrap(std::move(__first), std::move(__last), __value, __proj);
}
template <input_range _Rp, class _Tp, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
- _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
- borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
- return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
+ operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
+ return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);
}
};
} // namespace __find
inline namespace __cpo {
- inline constexpr auto find = __find::__fn{};
+inline constexpr auto find = __find::__fn{};
} // namespace __cpo
} // namespace ranges
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 17
+#endif // _LIBCPP_STD_VER >= 20
#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H