forked from mpusz/mp-units
refactor: 💥 make_xxx factory functions replaced with two-parameter constructors
Resolves #521
This commit is contained in:
@@ -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{}};
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user