refactor: 💥 magnitudes code cleanup + mag_pi is now mag<pi>

This commit is contained in:
Mateusz Pusz
2024-09-23 12:39:22 +02:00
parent 4492d42b91
commit 3671f64153
14 changed files with 494 additions and 666 deletions

View File

@@ -45,7 +45,7 @@ inline constexpr struct speed_of_light_in_vacuum final :
} // namespace si2019
inline constexpr struct magnetic_constant final :
named_unit<{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant;
named_unit<{u8"μ₀", "u_0"}, mag<4> * mag<pi> * mag_power<10, -7> * henry / metre> {} magnetic_constant;
} // namespace mp_units::si
```

View File

@@ -184,11 +184,14 @@ 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
inline constexpr struct mag_pi final : magnitude<std::numbers::pi_v<long double>> {} mag_pi;
struct pi : mag_constant {
static constexpr auto value = std::numbers::pi_v<long double>;
};
inline constexpr pi pi;
```
```cpp
inline constexpr struct degree final : named_unit<{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
inline constexpr struct degree final : named_unit<{u8"°", "deg"}, mag<pi> / mag<180> * si::radian> {} degree;
```