refactor: 💥 q_* UDL renamed to _q_*

We had some fun exploring the STD UDLs for potential collisions,
we have learnt our lesson and know how to proceed.
Now is high time to start behaving and obeying C++ rules.
This commit is contained in:
Mateusz Pusz committed 2020-09-09 19:20:35 +02:00
1 parent 2b408f19c0
commit 9527b39005
130 files changed
+2221 -2235

No files matched your search

@@ -90,7 +90,7 @@ representation types we have to obey similar rules::
This also applies when we want to create a quantity with a custom representation type
from a regular quantity value::
Length auto d = 123q_m;
Length auto d = 123_q_m;
si::length<si::metre, impl> d1(d); // OK
si::length<si::metre, expl> d2(d); // Compile-time error
si::length<si::metre, expl> d3(quantity_cast<expl>(d)); // OK
+1 -1
View File
@@ -130,7 +130,7 @@ coherent unit::
With the above we can now check what is the production rate::
DeskRate auto rate = quantity_cast<desk_per_hour>(3._d / 20q_min);
DeskRate auto rate = quantity_cast<desk_per_hour>(3._d / 20_q_min);
std::cout << "Desk rate: " << rate << '\n'; // prints 'Desk rate: 9 desk/h'
and how much wood is being consumed over a unit of time::
+19 -19
View File
@@ -27,28 +27,28 @@ The official :term:`quantity` definition states:
So the most common use case would be to create a vector or matrix of quantities::
fs_vector<si::length<si::metre>, 3> v = { 1q_m, 2q_m, 3q_m };
fs_vector<si::length<si::metre>, 3> u = { 3q_m, 2q_m, 1q_m };
fs_vector<si::length<si::kilometre>, 3> t = { 3q_km, 2q_km, 1q_km };
fs_vector<si::length<si::metre>, 3> v = { 1_q_m, 2_q_m, 3_q_m };
fs_vector<si::length<si::metre>, 3> u = { 3_q_m, 2_q_m, 1_q_m };
fs_vector<si::length<si::kilometre>, 3> t = { 3_q_km, 2_q_km, 1_q_km };
Having such definitions we can perform full dimensional analysis operations for the operations
allowed by the Linear Algebra rules. For example::
std::cout << "v + u = " << v + u << "\n";
std::cout << "v + t = " << v + t << "\n";
std::cout << "t[m] = " << vector<si::length<si::metre>>(t) << "\n";
std::cout << "v * u = " << v * u << "\n";
std::cout << "2q_m * v = " << 2q_m * v << "\n";
std::cout << "v + u = " << v + u << "\n";
std::cout << "v + t = " << v + t << "\n";
std::cout << "t[m] = " << vector<si::length<si::metre>>(t) << "\n";
std::cout << "v * u = " << v * u << "\n";
std::cout << "2_q_m * v = " << 2_q_m * v << "\n";
The above code works as expected and produces the following output:
.. code-block:: text
v + u = | 4 m 4 m 4 m |
v + t = | 3001 m 2002 m 1003 m |
t[m] = | 3000 m 2000 m 1000 m |
v * u = 10 m²
2q_m * v = | 2 m² 4 m² 6 m² |
v + u = | 4 m 4 m 4 m |
v + t = | 3001 m 2002 m 1003 m |
t[m] = | 3000 m 2000 m 1000 m |
v * u = 10 m²
2_q_m * v = | 2 m² 4 m² 6 m² |
Quantities of Linear Algebra Types
@@ -74,14 +74,14 @@ output:
.. code-block:: text
v + u = | 4 4 4 | m
v + t = | 3001 2002 1003 | m
t[m] = | 3000 2000 1000 | m
v * u = 10 m²
2q_m * v = | 2 4 6 | m²
v + u = | 4 4 4 | m
v + t = | 3001 2002 1003 | m
t[m] = | 3000 2000 1000 | m
v * u = 10 m²
2_q_m * v = | 2 4 6 | m²
.. seealso::
For more examples of Linear Algebra definition and operations please refer to
the :ref:`linear_algebra` example.
the :ref:`linear_algebra` example.
+5 -5
View File
@@ -26,7 +26,7 @@ will determine its type. The same applies to the resulting unit. For example:
using namespace units::physical::si;
constexpr auto result = 144q_km / 2q_h;
constexpr auto result = 144_q_km / 2_q_h;
static_assert(is_same_v<decltype(result)::dimension, dim_speed>);
static_assert(is_same_v<decltype(result)::unit, kilometre_per_hour>);
@@ -44,7 +44,7 @@ we forget to include a header file with the resulting dimension definition:
using namespace units::physical::si;
constexpr auto result = 144q_km / 2q_h;
constexpr auto result = 144_q_km / 2_q_h;
static_assert(is_same_v<decltype(result)::dimension,
unknown_dimension<exponent<dim_length, 1>, exponent<dim_time, -1>>>);
static_assert(is_same_v<decltype(result)::unit,
@@ -96,10 +96,10 @@ in your program. A typical example here are temporary results of a long calculat
{
Speed auto s1 = avg_speed(d, t);
auto temp1 = s1 * 200q_km; // intermediate unknown dimension
auto temp1 = s1 * 200_q_km; // intermediate unknown dimension
Speed auto s2 = temp1 / 50q_km; // back to known dimensions again
Length auto d2 = s2 * 4q_h;
Speed auto s2 = temp1 / 50_q_km; // back to known dimensions again
Length auto d2 = s2 * 4_q_h;
// ...
}