[libc++] Fix LWG 4265: std::midpoint should not accept const bool (#174579)
Fixes: #171324 --------- Co-authored-by: Hristo Hristov <hghristov.rmm@gmail.com>
This commit is contained in:
parent
f90cbc61af
commit
bfd139dacd
@ -164,7 +164,7 @@
|
||||
"`LWG4256 <https://wg21.link/LWG4256>`__","Incorrect constrains for ``function_ref`` constructors from ``nontype_t``","2025-11 (Kona)","","","`#171321 <https://github.com/llvm/llvm-project/issues/171321>`__",""
|
||||
"`LWG4257 <https://wg21.link/LWG4257>`__","Stream insertion for ``chrono::local_time`` should be constrained","2025-11 (Kona)","","","`#171322 <https://github.com/llvm/llvm-project/issues/171322>`__",""
|
||||
"`LWG4260 <https://wg21.link/LWG4260>`__","Query objects must be default constructible","2025-11 (Kona)","","","`#171323 <https://github.com/llvm/llvm-project/issues/171323>`__",""
|
||||
"`LWG4265 <https://wg21.link/LWG4265>`__","``std::midpoint`` should not accept ``const bool``","2025-11 (Kona)","","","`#171324 <https://github.com/llvm/llvm-project/issues/171324>`__",""
|
||||
"`LWG4265 <https://wg21.link/LWG4265>`__","``std::midpoint`` should not accept ``const bool``","2025-11 (Kona)","|Complete|","22","`#171324 <https://github.com/llvm/llvm-project/issues/171324>`__",""
|
||||
"`LWG4266 <https://wg21.link/LWG4266>`__","``layout_stride::mapping`` should treat empty mappings as exhaustive","2025-11 (Kona)","","","`#171325 <https://github.com/llvm/llvm-project/issues/171325>`__",""
|
||||
"`LWG4269 <https://wg21.link/LWG4269>`__","``unique_copy`` passes arguments to its predicate backwards","2025-11 (Kona)","","","`#171326 <https://github.com/llvm/llvm-project/issues/171326>`__",""
|
||||
"`LWG4272 <https://wg21.link/LWG4272>`__","For ``rank == 0``, ``layout_stride`` is atypically convertible","2025-11 (Kona)","","","`#171327 <https://github.com/llvm/llvm-project/issues/171327>`__",""
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__type_traits/is_void.h>
|
||||
#include <__type_traits/make_unsigned.h>
|
||||
#include <__type_traits/remove_cv.h>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
@ -31,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
template <class _Tp>
|
||||
requires(is_integral_v<_Tp> && !is_same_v<_Tp, bool>)
|
||||
requires(is_integral_v<_Tp> && !is_same_v<remove_cv_t<_Tp>, bool>)
|
||||
[[nodiscard]]
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr _Tp midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK {
|
||||
using _Up = make_unsigned_t<_Tp>;
|
||||
|
||||
@ -29,6 +29,12 @@ void* vp = nullptr;
|
||||
void test() {
|
||||
// expected-error@+1 {{no matching function for call to 'midpoint'}}
|
||||
(void)std::midpoint(false, true);
|
||||
// expected-error@+1 {{no matching function for call to 'midpoint'}}
|
||||
(void)std::midpoint<const bool>(false, true);
|
||||
// expected-error@+1 {{no matching function for call to 'midpoint'}}
|
||||
(void)std::midpoint<const volatile bool>(false, true);
|
||||
// expected-error@+1 {{no matching function for call to 'midpoint'}}
|
||||
(void)std::midpoint<volatile bool>(false, true);
|
||||
|
||||
// A couple of odd pointer types that should fail
|
||||
(void)std::midpoint(nullptr, nullptr); // expected-error {{no matching function for call to 'midpoint'}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user