docs: 2.2 release updated with mag_ratio

This commit is contained in:
Mateusz Pusz
2024-04-19 16:14:34 +01:00
parent f90a218705
commit 6ad831b573

View File

@@ -372,3 +372,28 @@ inside of the `mp_units::si` subnamespace and not in `mp_units::isq` like it was
(**breaking change**).
Also, the header itself was split into smaller pieces that improve C++20 modules definitions.
## `ratio` made an implementation detail of the library
We decided not to expose `ratio` and associated types in the public interface of the library
(**breaking change**). Standardization of it could be problematic as we have
[`std::ratio`](https://en.cppreference.com/w/cpp/numeric/ratio/ratio) already.
Alternatively, we introduced a new helper called `mag_ratio` to provide the magnitude of the unit
defined in terms of a rational conversion factor. Here is a comparison of the code with previous
and current definitions:
=== "Now"
```cpp
inline constexpr struct yard : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
inline constexpr struct foot : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot;
```
=== "Before"
```cpp
inline constexpr struct yard : named_unit<"yd", mag<ratio{9'144, 10'000}> * si::metre> {} yard;
inline constexpr struct foot : named_unit<"ft", mag<ratio{1, 3}> * yard> {} foot;
```