diff options
author | Sanjay Marreddi <sanjay.mareddi@gmail.com> | 2023-12-20 10:53:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-20 11:53:19 +0100 |
commit | c37734d40904ebe9c7cc345aab6be3649b0a903c (patch) | |
tree | 148fcf2c26b6126d386649f9181736591557341b /libcxx/include/__numeric | |
parent | d5abd8a1a9b5f60a16f6bfd983e1baed22313bae (diff) | |
download | llvm-c37734d40904ebe9c7cc345aab6be3649b0a903c.zip llvm-c37734d40904ebe9c7cc345aab6be3649b0a903c.tar.gz llvm-c37734d40904ebe9c7cc345aab6be3649b0a903c.tar.bz2 |
[libc++] Fix ability to explicitly instantiate std::midpoint (#74217)
std::midpoint is specified by having a pointer overload in
[numeric.ops.midpoint].
With the way the pointer overload is specified, users can expect that
calling
std::midpoint as `std::midpoint<T>(a, b)` should work, but it didn't in
libc++
due to the way the pointer overload was specified.
Fixes #67046
Diffstat (limited to 'libcxx/include/__numeric')
-rw-r--r-- | libcxx/include/__numeric/midpoint.h | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/libcxx/include/__numeric/midpoint.h b/libcxx/include/__numeric/midpoint.h index 986cb6e..5d715c2 100644 --- a/libcxx/include/__numeric/midpoint.h +++ b/libcxx/include/__numeric/midpoint.h @@ -48,12 +48,8 @@ midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK return __a + __half_diff; } -template <class _TPtr> -_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< - is_pointer_v<_TPtr> && is_object_v<remove_pointer_t<_TPtr>> && !is_void_v<remove_pointer_t<_TPtr>> && - (sizeof(remove_pointer_t<_TPtr>) > 0), - _TPtr> -midpoint(_TPtr __a, _TPtr __b) noexcept { +template <class _Tp, enable_if_t<is_object_v<_Tp> && !is_void_v<_Tp> && (sizeof(_Tp) > 0), int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr _Tp* midpoint(_Tp* __a, _Tp* __b) noexcept { return __a + std::midpoint(ptrdiff_t(0), __b - __a); } |