diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2024-12-05 10:49:03 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2024-12-05 11:21:12 +0300 |
commit | 681668b400e84754eb7acbc0e173491bb4dfc8b2 (patch) | |
tree | e809b0abb22e9c506c032e256effebcf9ea88dbd /contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h | |
parent | fe60cde3cf1989964159845c2929a65056a8dcf3 (diff) | |
download | ydb-681668b400e84754eb7acbc0e173491bb4dfc8b2.tar.gz |
Update libcxx to 18 Dec 3b0705827dbe711788c6b6bec3afa94205db1ce8
commit_hash:875d8582c26b8bf016af25e00ad77d9bbf081948
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h index d7c268bc6b..754e597130 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP___ALGORITHM_FIND_H #define _LIBCPP___ALGORITHM_FIND_H +#include <__algorithm/find_segment_if.h> #include <__algorithm/min.h> #include <__algorithm/unwrap_iter.h> #include <__bit/countr.h> @@ -18,8 +19,10 @@ #include <__functional/identity.h> #include <__functional/invoke.h> #include <__fwd/bit_reference.h> +#include <__iterator/segmented_iterator.h> #include <__string/constexpr_c_functions.h> #include <__type_traits/is_same.h> +#include <__utility/move.h> #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS # include <cwchar> @@ -118,8 +121,36 @@ __find_impl(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); } +// segmented iterator implementation + +template <class> +struct __find_segment; + +template <class _SegmentedIterator, + class _Tp, + class _Proj, + __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator +__find_impl(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { + return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj); +} + +template <class _Tp> +struct __find_segment { + const _Tp& __value_; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __find_segment(const _Tp& __value) : __value_(__value) {} + + template <class _InputIterator, class _Proj> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator + operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const { + return std::__find_impl(__first, __last, __value_, __proj); + } +}; + +// public API template <class _InputIterator, class _Tp> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { __identity __proj; return std::__rewrap_iter( |