From c1bcd5e034ab9000b1bd66dbdfcf822d59d1c1af Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Thu, 22 Jun 2023 16:56:52 -0700 Subject: [PATCH 1/2] P1383R2 More constexpr for cmath and complex --- source/numerics.tex | 282 ++++++++++++++++++++++---------------------- 1 file changed, 141 insertions(+), 141 deletions(-) diff --git a/source/numerics.tex b/source/numerics.tex index 680ca3dfe0..655ad07dd0 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -256,38 +256,38 @@ template constexpr T real(const complex&); template constexpr T imag(const complex&); - template T abs(const complex&); - template T arg(const complex&); + template constexpr T abs(const complex&); + template constexpr T arg(const complex&); template constexpr T norm(const complex&); template constexpr complex conj(const complex&); - template complex proj(const complex&); - template complex polar(const T&, const T& = T()); + template constexpr complex proj(const complex&); + template constexpr complex polar(const T&, const T& = T()); // \ref{complex.transcendentals}, transcendentals - template complex acos(const complex&); - template complex asin(const complex&); - template complex atan(const complex&); - - template complex acosh(const complex&); - template complex asinh(const complex&); - template complex atanh(const complex&); - - template complex cos (const complex&); - template complex cosh (const complex&); - template complex exp (const complex&); - template complex log (const complex&); - template complex log10(const complex&); - - template complex pow (const complex&, const T&); - template complex pow (const complex&, const complex&); - template complex pow (const T&, const complex&); - - template complex sin (const complex&); - template complex sinh (const complex&); - template complex sqrt (const complex&); - template complex tan (const complex&); - template complex tanh (const complex&); + template constexpr complex acos(const complex&); + template constexpr complex asin(const complex&); + template constexpr complex atan(const complex&); + + template constexpr complex acosh(const complex&); + template constexpr complex asinh(const complex&); + template constexpr complex atanh(const complex&); + + template constexpr complex cos (const complex&); + template constexpr complex cosh (const complex&); + template constexpr complex exp (const complex&); + template constexpr complex log (const complex&); + template constexpr complex log10(const complex&); + + template constexpr complex pow (const complex&, const T&); + template constexpr complex pow (const complex&, const complex&); + template constexpr complex pow (const T&, const complex&); + + template constexpr complex sin (const complex&); + template constexpr complex sinh (const complex&); + template constexpr complex sqrt (const complex&); + template constexpr complex tan (const complex&); + template constexpr complex tanh (const complex&); // \ref{complex.literals}, complex literals inline namespace literals { @@ -785,7 +785,7 @@ \indexlibrarymember{abs}{complex}% \begin{itemdecl} -template T abs(const complex& x); +template constexpr T abs(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -796,7 +796,7 @@ \indexlibrarymember{arg}{complex}% \begin{itemdecl} -template T arg(const complex& x); +template constexpr T arg(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -829,7 +829,7 @@ \indexlibrarymember{proj}{complex}% \begin{itemdecl} -template complex proj(const complex& x); +template constexpr complex proj(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -845,7 +845,7 @@ \indexlibrarymember{polar}{complex}% \begin{itemdecl} -template complex polar(const T& rho, const T& theta = T()); +template constexpr complex polar(const T& rho, const T& theta = T()); \end{itemdecl} \begin{itemdescr} @@ -867,7 +867,7 @@ \indexlibrarymember{acos}{complex}% \indexlibrarymember{cacos}{complex}% \begin{itemdecl} -template complex acos(const complex& x); +template constexpr complex acos(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -884,7 +884,7 @@ \indexlibrarymember{asin}{complex}% \indexlibrarymember{casin}{complex}% \begin{itemdecl} -template complex asin(const complex& x); +template constexpr complex asin(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -901,7 +901,7 @@ \indexlibrarymember{atan}{complex}% \indexlibrarymember{catan}{complex}% \begin{itemdecl} -template complex atan(const complex& x); +template constexpr complex atan(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -918,7 +918,7 @@ \indexlibrarymember{acosh}{complex}% \indexlibrarymember{cacosh}{complex}% \begin{itemdecl} -template complex acosh(const complex& x); +template constexpr complex acosh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -935,7 +935,7 @@ \indexlibrarymember{asinh}{complex}% \indexlibrarymember{casinh}{complex}% \begin{itemdecl} -template complex asinh(const complex& x); +template constexpr complex asinh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -952,7 +952,7 @@ \indexlibrarymember{atanh}{complex}% \indexlibrarymember{catanh}{complex}% \begin{itemdecl} -template complex atanh(const complex& x); +template constexpr complex atanh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -968,7 +968,7 @@ \indexlibrarymember{cos}{complex}% \begin{itemdecl} -template complex cos(const complex& x); +template constexpr complex cos(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -979,7 +979,7 @@ \indexlibrarymember{cosh}{complex}% \begin{itemdecl} -template complex cosh(const complex& x); +template constexpr complex cosh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -990,7 +990,7 @@ \indexlibrarymember{exp}{complex}% \begin{itemdecl} -template complex exp(const complex& x); +template constexpr complex exp(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1001,7 +1001,7 @@ \indexlibrarymember{log}{complex}% \begin{itemdecl} -template complex log(const complex& x); +template constexpr complex log(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1021,7 +1021,7 @@ \indexlibrarymember{log10}{complex}% \begin{itemdecl} -template complex log10(const complex& x); +template constexpr complex log10(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1037,9 +1037,9 @@ \indexlibrarymember{pow}{complex}% \begin{itemdecl} -template complex pow(const complex& x, const complex& y); -template complex pow(const complex& x, const T& y); -template complex pow(const T& x, const complex& y); +template constexpr complex pow(const complex& x, const complex& y); +template constexpr complex pow(const complex& x, const T& y); +template constexpr complex pow(const T& x, const complex& y); \end{itemdecl} \begin{itemdescr} @@ -1059,7 +1059,7 @@ \indexlibrarymember{sin}{complex}% \begin{itemdecl} -template complex sin(const complex& x); +template constexpr complex sin(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1070,7 +1070,7 @@ \indexlibrarymember{sinh}{complex}% \begin{itemdecl} -template complex sinh(const complex& x); +template constexpr complex sinh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1081,7 +1081,7 @@ \indexlibrarymember{sqrt}{complex}% \begin{itemdecl} -template complex sqrt(const complex& x); +template constexpr complex sqrt(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1101,7 +1101,7 @@ \indexlibrarymember{tan}{complex}% \begin{itemdecl} -template complex tan(const complex& x); +template constexpr complex tan(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1112,7 +1112,7 @@ \indexlibrarymember{tanh}{complex}% \begin{itemdecl} -template complex tanh(const complex& x); +template constexpr complex tanh(const complex& x); \end{itemdecl} \begin{itemdescr} @@ -1129,17 +1129,16 @@ \indexlibraryglobal{imag}% \indexlibraryglobal{norm}% \indexlibraryglobal{real}% -The following function templates shall have additional overloads: +The following function templates have additional constexpr overloads: \begin{codeblock} arg norm conj proj imag real \end{codeblock} -where \tcode{norm}, \tcode{conj}, \tcode{imag}, and \tcode{real} are \keyword{constexpr} overloads. \pnum \indextext{overloads!floating-point}% -The additional overloads shall be sufficient to ensure: +The additional constexpr overloads are sufficient to ensure: \begin{itemize} \item If the argument has a floating-point type \tcode{T}, @@ -1151,7 +1150,7 @@ \pnum \indexlibraryglobal{pow}% -Function template \tcode{pow} has additional overloads sufficient to ensure, +Function template \tcode{pow} has additional constexpr overloads sufficient to ensure, for a call with one argument of type \tcode{complex} and the other argument of type \tcode{T2} or \tcode{complex}, both arguments are effectively cast to \tcode{complex>}. @@ -8959,69 +8958,69 @@ #define math_errhandling @\seebelow@ namespace std { - @\placeholder{floating-point-type}@ acos(@\placeholder{floating-point-type}@ x); - float acosf(float x); - long double acosl(long double x); + constexpr @\placeholder{floating-point-type}@ acos(@\placeholder{floating-point-type}@ x); + constexpr float acosf(float x); + constexpr long double acosl(long double x); - @\placeholder{floating-point-type}@ asin(@\placeholder{floating-point-type}@ x); - float asinf(float x); - long double asinl(long double x); + constexpr @\placeholder{floating-point-type}@ asin(@\placeholder{floating-point-type}@ x); + constexpr float asinf(float x); + constexpr long double asinl(long double x); - @\placeholder{floating-point-type}@ atan(@\placeholder{floating-point-type}@ x); - float atanf(float x); - long double atanl(long double x); + constexpr @\placeholder{floating-point-type}@ atan(@\placeholder{floating-point-type}@ x); + constexpr float atanf(float x); + constexpr long double atanl(long double x); - @\placeholder{floating-point-type}@ atan2(@\placeholder{floating-point-type}@ y, @\placeholder{floating-point-type}@ x); - float atan2f(float y, float x); - long double atan2l(long double y, long double x); + constexpr @\placeholder{floating-point-type}@ atan2(@\placeholder{floating-point-type}@ y, @\placeholder{floating-point-type}@ x); + constexpr float atan2f(float y, float x); + constexpr long double atan2l(long double y, long double x); - @\placeholder{floating-point-type}@ cos(@\placeholder{floating-point-type}@ x); - float cosf(float x); - long double cosl(long double x); + constexpr @\placeholder{floating-point-type}@ cos(@\placeholder{floating-point-type}@ x); + constexpr float cosf(float x); + constexpr long double cosl(long double x); - @\placeholder{floating-point-type}@ sin(@\placeholder{floating-point-type}@ x); - float sinf(float x); - long double sinl(long double x); + constexpr @\placeholder{floating-point-type}@ sin(@\placeholder{floating-point-type}@ x); + constexpr float sinf(float x); + constexpr long double sinl(long double x); - @\placeholder{floating-point-type}@ tan(@\placeholder{floating-point-type}@ x); - float tanf(float x); - long double tanl(long double x); + constexpr @\placeholder{floating-point-type}@ tan(@\placeholder{floating-point-type}@ x); + constexpr float tanf(float x); + constexpr long double tanl(long double x); - @\placeholder{floating-point-type}@ acosh(@\placeholder{floating-point-type}@ x); - float acoshf(float x); - long double acoshl(long double x); + constexpr @\placeholder{floating-point-type}@ acosh(@\placeholder{floating-point-type}@ x); + constexpr float acoshf(float x); + constexpr long double acoshl(long double x); - @\placeholder{floating-point-type}@ asinh(@\placeholder{floating-point-type}@ x); - float asinhf(float x); - long double asinhl(long double x); + constexpr @\placeholder{floating-point-type}@ asinh(@\placeholder{floating-point-type}@ x); + constexpr float asinhf(float x); + constexpr long double asinhl(long double x); - @\placeholder{floating-point-type}@ atanh(@\placeholder{floating-point-type}@ x); - float atanhf(float x); - long double atanhl(long double x); + constexpr @\placeholder{floating-point-type}@ atanh(@\placeholder{floating-point-type}@ x); + constexpr float atanhf(float x); + constexpr long double atanhl(long double x); - @\placeholder{floating-point-type}@ cosh(@\placeholder{floating-point-type}@ x); - float coshf(float x); - long double coshl(long double x); + constexpr @\placeholder{floating-point-type}@ cosh(@\placeholder{floating-point-type}@ x); + constexpr float coshf(float x); + constexpr long double coshl(long double x); - @\placeholder{floating-point-type}@ sinh(@\placeholder{floating-point-type}@ x); - float sinhf(float x); - long double sinhl(long double x); + constexpr @\placeholder{floating-point-type}@ sinh(@\placeholder{floating-point-type}@ x); + constexpr float sinhf(float x); + constexpr long double sinhl(long double x); - @\placeholder{floating-point-type}@ tanh(@\placeholder{floating-point-type}@ x); - float tanhf(float x); - long double tanhl(long double x); + constexpr @\placeholder{floating-point-type}@ tanh(@\placeholder{floating-point-type}@ x); + constexpr float tanhf(float x); + constexpr long double tanhl(long double x); - @\placeholder{floating-point-type}@ exp(@\placeholder{floating-point-type}@ x); - float expf(float x); - long double expl(long double x); + constexpr @\placeholder{floating-point-type}@ exp(@\placeholder{floating-point-type}@ x); + constexpr float expf(float x); + constexpr long double expl(long double x); - @\placeholder{floating-point-type}@ exp2(@\placeholder{floating-point-type}@ x); - float exp2f(float x); - long double exp2l(long double x); + constexpr @\placeholder{floating-point-type}@ exp2(@\placeholder{floating-point-type}@ x); + constexpr float exp2f(float x); + constexpr long double exp2l(long double x); - @\placeholder{floating-point-type}@ expm1(@\placeholder{floating-point-type}@ x); - float expm1f(float x); - long double expm1l(long double x); + constexpr @\placeholder{floating-point-type}@ expm1(@\placeholder{floating-point-type}@ x); + constexpr float expm1f(float x); + constexpr long double expm1l(long double x); constexpr @\placeholder{floating-point-type}@ frexp(@\placeholder{floating-point-type}@ value, int* exp); constexpr float frexpf(float value, int* exp); @@ -9035,21 +9034,21 @@ constexpr float ldexpf(float x, int exp); constexpr long double ldexpl(long double x, int exp); - @\placeholder{floating-point-type}@ log(@\placeholder{floating-point-type}@ x); - float logf(float x); - long double logl(long double x); + constexpr @\placeholder{floating-point-type}@ log(@\placeholder{floating-point-type}@ x); + constexpr float logf(float x); + constexpr long double logl(long double x); - @\placeholder{floating-point-type}@ log10(@\placeholder{floating-point-type}@ x); - float log10f(float x); - long double log10l(long double x); + constexpr @\placeholder{floating-point-type}@ log10(@\placeholder{floating-point-type}@ x); + constexpr float log10f(float x); + constexpr long double log10l(long double x); - @\placeholder{floating-point-type}@ log1p(@\placeholder{floating-point-type}@ x); - float log1pf(float x); - long double log1pl(long double x); + constexpr @\placeholder{floating-point-type}@ log1p(@\placeholder{floating-point-type}@ x); + constexpr float log1pf(float x); + constexpr long double log1pl(long double x); - @\placeholder{floating-point-type}@ log2(@\placeholder{floating-point-type}@ x); - float log2f(float x); - long double log2l(long double x); + constexpr @\placeholder{floating-point-type}@ log2(@\placeholder{floating-point-type}@ x); + constexpr float log2f(float x); + constexpr long double log2l(long double x); constexpr @\placeholder{floating-point-type}@ logb(@\placeholder{floating-point-type}@ x); constexpr float logbf(float x); @@ -9067,9 +9066,9 @@ constexpr float scalblnf(float x, long int n); constexpr long double scalblnl(long double x, long int n); - @\placeholder{floating-point-type}@ cbrt(@\placeholder{floating-point-type}@ x); - float cbrtf(float x); - long double cbrtl(long double x); + constexpr @\placeholder{floating-point-type}@ cbrt(@\placeholder{floating-point-type}@ x); + constexpr float cbrtf(float x); + constexpr long double cbrtl(long double x); // \ref{c.math.abs}, absolute values constexpr int abs(int j); // freestanding @@ -9081,37 +9080,37 @@ constexpr float fabsf(float x); constexpr long double fabsl(long double x); - @\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y); - float hypotf(float x, float y); - long double hypotl(long double x, long double y); + constexpr @\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y); + constexpr float hypotf(float x, float y); + constexpr long double hypotl(long double x, long double y); // \ref{c.math.hypot3}, three-dimensional hypotenuse - @\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y, - @\placeholder{floating-point-type}@ z); + constexpr @\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y, + @\placeholder{floating-point-type}@ z); - @\placeholder{floating-point-type}@ pow(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y); - float powf(float x, float y); - long double powl(long double x, long double y); + constexpr @\placeholder{floating-point-type}@ pow(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y); + constexpr float powf(float x, float y); + constexpr long double powl(long double x, long double y); - @\placeholder{floating-point-type}@ sqrt(@\placeholder{floating-point-type}@ x); - float sqrtf(float x); - long double sqrtl(long double x); + constexpr @\placeholder{floating-point-type}@ sqrt(@\placeholder{floating-point-type}@ x); + constexpr float sqrtf(float x); + constexpr long double sqrtl(long double x); - @\placeholder{floating-point-type}@ erf(@\placeholder{floating-point-type}@ x); - float erff(float x); - long double erfl(long double x); + constexpr @\placeholder{floating-point-type}@ erf(@\placeholder{floating-point-type}@ x); + constexpr float erff(float x); + constexpr long double erfl(long double x); - @\placeholder{floating-point-type}@ erfc(@\placeholder{floating-point-type}@ x); - float erfcf(float x); - long double erfcl(long double x); + constexpr @\placeholder{floating-point-type}@ erfc(@\placeholder{floating-point-type}@ x); + constexpr float erfcf(float x); + constexpr long double erfcl(long double x); - @\placeholder{floating-point-type}@ lgamma(@\placeholder{floating-point-type}@ x); - float lgammaf(float x); - long double lgammal(long double x); + constexpr @\placeholder{floating-point-type}@ lgamma(@\placeholder{floating-point-type}@ x); + constexpr float lgammaf(float x); + constexpr long double lgammal(long double x); - @\placeholder{floating-point-type}@ tgamma(@\placeholder{floating-point-type}@ x); - float tgammaf(float x); - long double tgammal(long double x); + constexpr @\placeholder{floating-point-type}@ tgamma(@\placeholder{floating-point-type}@ x); + constexpr float tgammaf(float x); + constexpr long double tgammal(long double x); constexpr @\placeholder{floating-point-type}@ ceil(@\placeholder{floating-point-type}@ x); constexpr float ceilf(float x); @@ -9423,7 +9422,8 @@ \indexlibrary{\idxcode{hypot}!3-argument form}% \begin{itemdecl} -@\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y, @\placeholder{floating-point-type}@ z); +constexpr @\placeholder{floating-point-type}@ hypot(@\placeholder{floating-point-type}@ x, @\placeholder{floating-point-type}@ y, + @\placeholder{floating-point-type}@ z); \end{itemdecl} \begin{itemdescr} From 8571e9454c7651995d72df8c3002bd97137304c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Fri, 21 Jul 2023 21:30:35 +0100 Subject: [PATCH 2/2] [version.syn] Bump value of __cpp_lib_constexpr_cmath --- source/support.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/support.tex b/source/support.tex index 87b4bec74a..7bf343e136 100644 --- a/source/support.tex +++ b/source/support.tex @@ -600,7 +600,7 @@ #define @\defnlibxname{cpp_lib_constexpr_algorithms}@ 202306L // also in \libheader{algorithm}, \libheader{utility} #define @\defnlibxname{cpp_lib_constexpr_bitset}@ 202207L // also in \libheader{bitset} #define @\defnlibxname{cpp_lib_constexpr_charconv}@ 202207L // also in \libheader{charconv} -#define @\defnlibxname{cpp_lib_constexpr_cmath}@ 202202L // also in \libheader{cmath}, \libheader{cstdlib} +#define @\defnlibxname{cpp_lib_constexpr_cmath}@ 202306L // also in \libheader{cmath}, \libheader{cstdlib} #define @\defnlibxname{cpp_lib_constexpr_complex}@ 201711L // also in \libheader{complex} #define @\defnlibxname{cpp_lib_constexpr_dynamic_alloc}@ 201907L // also in \libheader{memory} #define @\defnlibxname{cpp_lib_constexpr_functional}@ 201907L // freestanding, also in \libheader{functional}