You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<cmath> is one of the STL's most complicated headers (despite the seeming simplicity) because of the "sufficient additional overloads" Standardese in WG21-N4861 [cmath.syn]/2. There's a system of overloads for float and long double (in addition to double provided by the UCRT), and then templates to handle mixed/integral arguments.
There's also some variation - fma and remquo, added in C++11, use a newer technique powered by if constexpr:
(I suspect that float, float arguments are always handled by the separate overload, so there is currently no way to activate it for the template.)
Due to [namespace.std]/6 forbidding forming pointers/references to Standard Library functions (except for "addressable functions"), I believe it may now be unobservable whether the float and long double overloads exist separately. If that's the case, now that if constexpr is available for unconditional use, we should consider eliminating the separate overloads and centralizing everything in remquo-style templates.
Again, due to the complexity, changing anything here is relatively high-risk, but it's not impossible.
The text was updated successfully, but these errors were encountered:
I think merging float and long double overloads into the template overload still allows taking their addresses, so whether they are addressable doesn't matter...
However, if we really do so, std::fma({}, {}, {}) will compile when <cmath> is included (the non-template double overload from UCRT will be selected). Current synopsis in [cmath.syn]/2 enforces that std::fma({}, {}, {}) is ambiguous, which can't be changed by additional overloads.
LWG-3950 is related. It seems to me that "additional overloads" in the standard wording is always problematic because it's unclear whether additional and explicitly specified overloads can be fused.
Related to #189.
<cmath>
is one of the STL's most complicated headers (despite the seeming simplicity) because of the "sufficient additional overloads" Standardese in WG21-N4861 [cmath.syn]/2. There's a system of overloads forfloat
andlong double
(in addition todouble
provided by the UCRT), and then templates to handle mixed/integral arguments.There's also some variation -
fma
andremquo
, added in C++11, use a newer technique powered byif constexpr
:STL/stl/inc/cmath
Lines 548 to 562 in 530bdc5
(I suspect that
float, float
arguments are always handled by the separate overload, so there is currently no way to activate it for the template.)Due to [namespace.std]/6 forbidding forming pointers/references to Standard Library functions (except for "addressable functions"), I believe it may now be unobservable whether the
float
andlong double
overloads exist separately. If that's the case, now thatif constexpr
is available for unconditional use, we should consider eliminating the separate overloads and centralizing everything inremquo
-style templates.Again, due to the complexity, changing anything here is relatively high-risk, but it's not impossible.
The text was updated successfully, but these errors were encountered: