From 47344b13bd8a97778f5ccae5236f240053af61e9 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 28 Sep 2024 15:20:41 +0200 Subject: [PATCH] refactor: `pi` `mag_constant` refactored to be one-liner --- docs/users_guide/framework_basics/systems_of_units.md | 5 ++--- src/core/include/mp-units/framework/magnitude.h | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/users_guide/framework_basics/systems_of_units.md b/docs/users_guide/framework_basics/systems_of_units.md index 9e1cf9f0..6f61cc10 100644 --- a/docs/users_guide/framework_basics/systems_of_units.md +++ b/docs/users_guide/framework_basics/systems_of_units.md @@ -184,10 +184,9 @@ For some units, a magnitude might also be irrational. The best example here is a is defined using a floating-point magnitude having a factor of the number π (Pi): ```cpp -struct pi : mag_constant { +inline constexpr struct pi : mag_constant { static constexpr auto value = std::numbers::pi_v; -}; -inline constexpr pi pi; +} pi; ``` ```cpp diff --git a/src/core/include/mp-units/framework/magnitude.h b/src/core/include/mp-units/framework/magnitude.h index 32fdd81d..4cb50ed1 100644 --- a/src/core/include/mp-units/framework/magnitude.h +++ b/src/core/include/mp-units/framework/magnitude.h @@ -584,10 +584,9 @@ constexpr Magnitude auto mag_power = pow(mag); /** * @brief A convenient Magnitude constant for pi, which we can manipulate like a regular number. */ -struct pi : mag_constant { +inline constexpr struct pi : mag_constant { static constexpr auto value = std::numbers::pi_v; -}; -inline constexpr pi pi; +} pi; [[deprecated("Use `mag` instead")]] inline constexpr Magnitude auto mag_pi = mag;