mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
docs: 2.2 release updated with mag_ratio
This commit is contained in:
@@ -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;
|
||||
```
|
||||
|
Reference in New Issue
Block a user