For some reason, clang++ (but not g++) complains about:
constexpr double invdecayf1m(double x) {
return -log1p(-x);
}
telling me that
non-constexpr function 'log1p' cannot be used in a constant expression
return -log1p(-x);
Why aren't common mathematical functions declared in <cmath>
all declared to be “constexpr
functions”?
I think the only reason is nobody wrote a proposal to make them constexpr. In general it is possible as they are pure functions. Implementations can use compiler intrinsics to implement them for theier lib, so no "real" implementation is needed. But without proposal you can not count on constexpr
implementations of these features.