[libcxx-commits] [libcxx] [libc++] Fix LWG 4265: std::midpoint should not accept const bool (PR #174579)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 6 22:15:33 PST 2026


================
@@ -35,8 +35,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 20
 template <class _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp>
-midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK {
+_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<
+    is_integral_v<_Tp> && !is_same_v<bool, __remove_cv_t<_Tp>> && !is_null_pointer_v<_Tp>,
----------------
frederick-vs-ja wrote:

Also, it's possibly better (for reading) to use standard `remove_cv_t`. And please clang-format the changes.

https://github.com/llvm/llvm-project/pull/174579


More information about the libcxx-commits mailing list