[libcxx-commits] [libcxx] [libc++][math] Implement constexpr {round, roundl}. (PR #226377)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 27 05:07:50 PDT 2026
https://github.com/zhangweize9-cyber updated https://github.com/llvm/llvm-project/pull/226377
>From 4f28040e7ad398d35d12992676635f308faa25fd Mon Sep 17 00:00:00 2001
From: zhangweize9-cyber <zhangweize9 at gmail.com>
Date: Fri, 25 Sep 2026 14:09:47 +0800
Subject: [PATCH] [libc++][math] Implement constexpr {round, roundl} Add
`_LIBCPP_CONSTEXPR_SINCE_CXX23` as required by P0533R9.
---
libcxx/include/__math/rounding_functions.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__math/rounding_functions.h b/libcxx/include/__math/rounding_functions.h
index aadeb395fa2eb..a66c873c8f5e6 100644
--- a/libcxx/include/__math/rounding_functions.h
+++ b/libcxx/include/__math/rounding_functions.h
@@ -204,14 +204,16 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
// round
-[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 float round(float __x) _NOEXCEPT {
+ return __builtin_round(__x);
+}
template <class = int>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
return __builtin_round(__x);
}
-[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_CXX23 long double round(long double __x) _NOEXCEPT {
return __builtin_roundl(__x);
}
More information about the libcxx-commits
mailing list