refactor: 💥 make_xxx factory functions replaced with two-parameter constructors

Resolves #521
This commit is contained in:
Mateusz Pusz
2023-11-28 11:52:37 +01:00
parent 80129b32d7
commit fa596fffc6
12 changed files with 143 additions and 175 deletions

View File

@@ -191,10 +191,10 @@ Quantity auto q = la_vector{1, 2, 3} * isq::velocity[m / s];
In case there is an ambiguity of `operator*` between **mp-units** and a linear algebra library, we can
either:
- use `make_quantity` factory function
- use two-parameter constructor
```cpp
Quantity auto q = make_quantity<isq::velocity[m / s]>(la_vector{1, 2, 3});
Quantity auto q = quantity{la_vector{1, 2, 3}, isq::velocity[m / s]};
```
- provide a dedicated overload of `operator*` that will resolve the ambiguity and wrap the above
@@ -203,7 +203,7 @@ either:
template<Reference R>
Quantity auto operator*(la_vector rep, R)
{
return make_quantity<R{}>(rep);
return quantity{rep, R{}};
}
```

View File

@@ -102,11 +102,11 @@ quantity_point qp3 = mean_sea_level - 42 * m;
Similarly to [creation of a quantity](../../getting_started/quick_start.md#creating-a-quantity),
if someone does not like the operator-based syntax to create a `quantity_point`, the same results
can be achieved with `make_quantity_point` factory function:
can be achieved with two-parameter constructor:
```cpp
quantity_point qp4 = make_quantity_point<mean_sea_level>(42 * m);
quantity_point qp5 = make_quantity_point<mean_sea_level>(-42 * m);
quantity_point qp4{42 * m, mean_sea_level};
quantity_point qp5{-42 * m, mean_sea_level};
```
The provided `quantity` representing an offset from the origin is stored inside the `quantity_point`