refactor: ♻️ unitless renamed to one

Resolves #27
This commit is contained in:
Mateusz Pusz committed 2020-09-09 11:20:55 +02:00
1 parent dba2b7f44f
commit 3e9d5ca189
11 files changed
+47 -48

No files matched your search

+1 -1
View File
@@ -28,6 +28,6 @@ The same constant defined for natural units may be provided as::
namespace natural {
template<ScalableNumber Rep = double>
inline constexpr auto speed_of_light = speed<unitless, Rep>(1);
inline constexpr auto speed_of_light = speed<one, Rep>(1);
}
+8 -8
View File
@@ -110,16 +110,16 @@ represent numbers it would be highly uncomfortable to every time type::
const auto d1 = 10q_km;
const auto d2 = 3q_km;
if(d1 / d2 > dimensionless<unitless, 2>) {
if(d1 / d2 > dimensionless<one, 2>) {
// ...
}
or::
const auto fill_time_left = (box.height / box.fill_level(measured_mass) -
dimensionless<unitless, 1>) * fill_time;
dimensionless<one, 1>) * fill_time;
This is why it was decided to allow the ``dimensionless<unitless>`` quantity of any
This is why it was decided to allow the ``dimensionless<one>`` quantity of any
representation type to be implicitly constructible from this representation type.
With that the above examples can be rewritten as follows::
@@ -133,7 +133,7 @@ and::
const auto fill_time_left = (box.height / box.fill_level(measured_mass) - 1) * fill_time;
The above is true only for dimensionless quantities of `unitless` unit. If our quantity have a unit with
The above is true only for dimensionless quantities of `one` unit. If our quantity have a unit with
ratio different than ``1`` the implicit conversion will not happen. This is to prevent cases were the code
could be ambiguous. For example::
@@ -148,14 +148,14 @@ either change the type of the resulting unit to the one having ``ratio(1)`` (:te
Dimensionless auto foo(Length auto d1, Length auto d2)
{
return quantity_cast<unitless>(d1 / d2) + 1;
return quantity_cast<one>(d1 / d2) + 1;
}
or to explicitly state what is the unit of our dimensionless value, e.g. `unitless`, `percent`, etc::
or to explicitly state what is the unit of our dimensionless value, e.g. `one`, `percent`, etc::
Dimensionless auto foo(Length auto d1, Length auto d2)
{
return d1 / d2 + dimensionless<unitless>(1);
return d1 / d2 + dimensionless<one>(1);
}
There is one more important point to note here. As the the dimensionless quantity is more than just
@@ -166,7 +166,7 @@ code will not compile::
To make it compile fine we have to either explicitly get the value stored in the quantity::
auto v = std::exp(quantity_cast<unitless>(10q_m / 5q_m).count());
auto v = std::exp(quantity_cast<one>(10q_m / 5q_m).count());
or use a mathematical wrapper function from `units` namespace::
+3 -3
View File
@@ -167,7 +167,7 @@ Whenever we divide two quantities of the same dimension we end up with a
:term:`dimensionless quantity` otherwise known as :term:`quantity of dimension one`::
static_assert(10q_km / 5q_km == 2);
static_assert(std::is_same_v<decltype(10q_km / 5q_km), quantity<dim_one, unitless, std::int64_t>>);
static_assert(std::is_same_v<decltype(10q_km / 5q_km), quantity<dim_one, one, std::int64_t>>);
According to the official ISO definition `dim_one` is a dimension "for which all the
exponents of the factors corresponding to the base quantities in its quantity dimension
@@ -189,10 +189,10 @@ are provided::
There are two special units provided for usage with such a quantity:
- `unitless` which is the :ref:`coherent unit` of dimensionless quantity and does not
- `one` which is the :ref:`coherent unit` of dimensionless quantity and does not
provide any textual symbol (according to the ISO definition "the measurement units and
values of quantities of dimension one are numbers"),
- `percent` which has the symbol ``%`` and ``ratio(1, 100)`` of the `unitless` unit.
- `percent` which has the symbol ``%`` and ``ratio(1, 100)`` of the `one` unit.
For example the following code::