diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-25 17:35:41 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:22 +0000 |
| commit | e710425beb3de4adcf4d601da2f224503f876b6d (patch) | |
| tree | aca526ac7dde15560ae28f549319b25647f28363 /contrib/llvm-project/libcxx/include/__algorithm/find.h | |
| parent | 1bc094c4a0e74dba87a5eb98cf138426a19f702d (diff) | |
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/find.h')
| -rw-r--r-- | contrib/llvm-project/libcxx/include/__algorithm/find.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find.h b/contrib/llvm-project/libcxx/include/__algorithm/find.h index 754e597130c5..7d7631b6e98a 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/find.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/find.h @@ -21,8 +21,11 @@ #include <__fwd/bit_reference.h> #include <__iterator/segmented_iterator.h> #include <__string/constexpr_c_functions.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> +#include <__type_traits/is_signed.h> #include <__utility/move.h> +#include <limits> #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS # include <cwchar> @@ -76,6 +79,22 @@ __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +// TODO: This should also be possible to get right with different signedness +// cast integral types to allow vectorization +template <class _Tp, + class _Up, + class _Proj, + __enable_if_t<__is_identity<_Proj>::value && !__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && + is_integral<_Tp>::value && is_integral<_Up>::value && + is_signed<_Tp>::value == is_signed<_Up>::value, + int> = 0> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* +__find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) { + if (__value < numeric_limits<_Tp>::min() || __value > numeric_limits<_Tp>::max()) + return __last; + return std::__find_impl(__first, __last, _Tp(__value), __proj); +} + // __bit_iterator implementation template <bool _ToFind, class _Cp, bool _IsConst> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst> |
