diff --git a/content/more-constexpr-cmath.md b/content/more-constexpr-cmath.md new file mode 100644 index 0000000..e976f3d --- /dev/null +++ b/content/more-constexpr-cmath.md @@ -0,0 +1,27 @@ +--- +execute: false +--- + +## What It Does + +Most functions in the `` and `` headers are made `constexpr`. + +## Why It Matters + +Historically, while arithmetic expressions such as addition and multiplication +between floating-point operands could be used in constant expressions, +common mathematical functions such as `std::sqrt` or `std::pow` couldn't be. +This meant that some computations had to be done unnecessarily at runtime, +or the user had to re-implement a `constexpr` version +of the ``functions themselves. +The same applies to the corresponding functions in ``. + +## Example + +```cpp +#include +#include + +constexpr double sqrt_10 = std::sqrt(10); +constexpr std::complex i = std::sqrt(std::complex(-1)); +``` diff --git a/features_cpp26.yaml b/features_cpp26.yaml index 78a0e10..949f0cb 100644 --- a/features_cpp26.yaml +++ b/features_cpp26.yaml @@ -309,8 +309,10 @@ features: - desc: "More constexpr for `` and ``" paper: P1383 + summary: "More mathematical functions are now `constexpr`, such as `std::sqrt`." + content: more-constexpr-cmath.md lib: true - support: [GCC 4.6] + support: [GCC 4.6 (partial)] ftm: - name: __cpp_lib_constexpr_cmath value: 202306L