mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 02:47:16 +02:00
18
README.md
18
README.md
@ -28,11 +28,11 @@ analysis and unit/quantity manipulation. The basic idea and design heavily bases
|
||||
Here is a small example of possible operations:
|
||||
|
||||
```cpp
|
||||
#include <units/physical/si/area.h>
|
||||
#include <units/physical/si/frequency.h>
|
||||
#include <units/physical/si/speed.h>
|
||||
#include <units/isq/si/area.h>
|
||||
#include <units/isq/si/frequency.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
|
||||
using namespace units::physical::si;
|
||||
using namespace units::isq::si;
|
||||
|
||||
// simple numeric operations
|
||||
static_assert(10_q_km / 2 == 5_q_km);
|
||||
@ -62,12 +62,12 @@ the below example for a quick preview of basic library features:
|
||||
|
||||
```cpp
|
||||
#include <units/format.h>
|
||||
#include <units/physical/si/speed.h>
|
||||
#include <units/physical/si/international/speed.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/international/speed.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace units::physical;
|
||||
using namespace units::isq;
|
||||
|
||||
constexpr Speed auto avg_speed(Length auto d, Time auto t)
|
||||
{
|
||||
@ -76,8 +76,8 @@ constexpr Speed auto avg_speed(Length auto d, Time auto t)
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
|
||||
constexpr Speed auto v1 = 110 * km / h;
|
||||
constexpr Speed auto v2 = avg_speed(220_q_km, 2_q_h);
|
||||
|
@ -124,104 +124,104 @@ set(unitsSphinxDocs
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/dimensionless.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/unknown.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/natural.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/natural/constants.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/natural/dimensions.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/natural/units.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/constants.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/dimensions.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/units.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_cgs.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/cgs/time.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_cgs.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/cgs/time.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/dimensions_and_concepts.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/dimensions_and_concepts.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_fps.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/time.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/fps/volume.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_fps.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/time.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/fps/volume.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_iau.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/iau/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_iau.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/iau/length.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_imperial.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/imperial/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_imperial.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/imperial/length.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_international.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/international/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/international/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/international/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/international/volume.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_international.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/international/volume.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/absorbed_dose.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/amount_of_substance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/capacitance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/catalytic_activity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/charge_density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/concentration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/conductance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/constants.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/current_density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/dynamic_viscosity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/electric_charge.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/electric_current.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/electric_field_strength.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/frequency.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/heat_capacity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/inductance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/luminance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/luminous_intensity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/magnetic_flux.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/magnetic_induction.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/molar_energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/momentum.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/permeability.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/permittivity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/prefixes.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/resistance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/surface_tension.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/thermal_conductivity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/thermodynamic_temperature.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/time.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/voltage.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/volume.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/absorbed_dose.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/acceleration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/amount_of_substance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/area.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/capacitance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/catalytic_activity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/charge_density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/concentration.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/conductance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/constants.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/current_density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/density.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/dynamic_viscosity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/electric_charge.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/electric_current.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/electric_field_strength.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/force.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/frequency.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/heat_capacity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/inductance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/luminance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/luminous_intensity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/magnetic_flux.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/magnetic_induction.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/mass.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/molar_energy.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/momentum.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/permeability.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/permittivity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/power.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/prefixes.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/pressure.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/resistance.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/speed.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/surface_tension.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/thermal_conductivity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/thermodynamic_temperature.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/time.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/voltage.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/volume.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_typographic.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/typographic/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_typographic.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/typographic/length.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si_us.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/physical/si/us/length.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_us.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si/us/length.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/references.rst"
|
||||
|
||||
|
@ -6,7 +6,7 @@ Design Deep Dive
|
||||
For brevity all the code examples in this chapter assume::
|
||||
|
||||
using namespace units;
|
||||
using namespace units::physical;
|
||||
using namespace units::isq;
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
@ -63,4 +63,4 @@ Library Directories Structure
|
||||
|
||||
While working with predefined systems please always include a header file with all
|
||||
the definitions for the current system to limit the possibility of an ODR violation
|
||||
(e.g. *units/physical/si/si.h*).
|
||||
(e.g. *units/isq/si/si.h*).
|
||||
|
@ -23,9 +23,9 @@ The above solution does provide a good developer's experience but a really poor
|
||||
user. If we will get a compilation error message containing ``dim_capacitance`` in most cases
|
||||
the compiler will print the following type instead of the alias::
|
||||
|
||||
units::detail::derived_dimension_base<units::exponent<units::physical::si::dim_electric_current, 2, 1>,
|
||||
units::exponent<units::physical::si::dim_length, -2, 1>, units::exponent<units::physical::si::dim_mass,
|
||||
-1, 1>, units::exponent<units::physical::si::dim_time, 4, 1> >
|
||||
units::detail::derived_dimension_base<units::exponent<units::isq::si::dim_electric_current, 2, 1>,
|
||||
units::exponent<units::isq::si::dim_length, -2, 1>, units::exponent<units::isq::si::dim_mass,
|
||||
-1, 1>, units::exponent<units::isq::si::dim_time, 4, 1> >
|
||||
|
||||
You can notice that in case of **mp-units** even this long syntax was carefully selected to
|
||||
provide quite good user experience (some other units libraries produce a type that cannot easily
|
||||
|
@ -30,10 +30,10 @@ different dimensions (i.e. height, width, and depth) all of them will just be
|
||||
measured in meters.
|
||||
|
||||
|
||||
Why other systems are defined in the `physical::si` namespace?
|
||||
Why other systems are defined in the `isq::si` namespace?
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
All systems defined in the `physical::si` namespace are defined in terms of
|
||||
All systems defined in the `isq::si` namespace are defined in terms of
|
||||
base units that are convertible to the :term:`SI` units. This enables conversions
|
||||
of units of the same physical dimension between different systems.
|
||||
|
||||
@ -125,7 +125,7 @@ error: reference to ‘time’ is ambiguous
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Unfortunately, if `using-directives <https://en.cppreference.com/w/cpp/language/namespace#Using-directives>`_
|
||||
(i.e. ``using namespace units::physical::si``) are being used, `units::physical::si::time`
|
||||
(i.e. ``using namespace units::isq::si``) are being used, `units::isq::si::time`
|
||||
will collide with C `time <https://en.cppreference.com/w/c/chrono/time>`_ function. In
|
||||
such a case the library's ``time`` function needs to be prefixed with at least one (or all)
|
||||
namespace names.
|
||||
|
@ -6,7 +6,7 @@ Framework Basics
|
||||
For brevity all the code examples in this chapter assume::
|
||||
|
||||
using namespace units;
|
||||
using namespace units::physical;
|
||||
using namespace units::isq;
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
@ -171,7 +171,7 @@ provided. For example the SI base dimension of length can be defined as::
|
||||
}
|
||||
|
||||
In the above code sample ``"L"`` is an base dimension's unique identifier
|
||||
and `physical::si::metre` is a :term:`base unit` of this base dimension. We can
|
||||
and `isq::si::metre` is a :term:`base unit` of this base dimension. We can
|
||||
obtain those back easily with::
|
||||
|
||||
static_assert(si::dim_length::symbol == "L");
|
||||
@ -206,8 +206,8 @@ The above dimensions can be defined in the library with the
|
||||
|
||||
}
|
||||
|
||||
In the above code sample `physical::si::square_metre` and
|
||||
`physical::si::metre_per_second` are the
|
||||
In the above code sample `isq::si::square_metre` and
|
||||
`isq::si::metre_per_second` are the
|
||||
:term:`coherent derived units <coherent derived unit>` of those derived dimensions.
|
||||
|
||||
Coherent unit argument is followed by the list of exponents that form this
|
||||
|
@ -69,7 +69,7 @@ values the library provides :abbr:`UDL (User Defined Literal)` s for each
|
||||
|
||||
Thanks to them the same code can be as simple as::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
auto d = 123._q_km; // si::length<si::kilometre, long double>
|
||||
auto v = 70_q_km_per_h; // si::speed<si::kilometre_per_hour, std::int64_t>
|
||||
|
||||
@ -98,7 +98,7 @@ They are defined using a special `one_rep` representation type::
|
||||
|
||||
With the above our code can look as follows::
|
||||
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
auto d = 123. * km; // si::length<si::kilometre, double>
|
||||
auto v = 70 * km / h; // si::speed<si::kilometre_per_hour, int>
|
||||
|
||||
@ -121,13 +121,13 @@ UDLs are helpful but they also have some disadvantages compared to Unit Constant
|
||||
|
||||
- UDLs::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
auto v1 = 120_q_km / 2_q_h;
|
||||
auto v2 = length<kilometre>(distance) / time<hour>(duration);
|
||||
|
||||
- Unit Constants::
|
||||
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
auto v1 = 120 * km / (2 * h);
|
||||
auto v2 = distance * km / (duration * h);
|
||||
|
||||
@ -139,14 +139,14 @@ UDLs are helpful but they also have some disadvantages compared to Unit Constant
|
||||
|
||||
- UDLs::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::si::cgs::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::cgs::literals;
|
||||
auto d = 1_q_cm; // FAILS TO COMPILE
|
||||
|
||||
- Unit Constants::
|
||||
|
||||
inline constexpr auto si_cm = units::physical::si::unit_constants::cm;
|
||||
inline constexpr auto cgs_cm = units::physical::si::cgs::unit_constants::cm;
|
||||
inline constexpr auto si_cm = units::isq::si::unit_constants::cm;
|
||||
inline constexpr auto cgs_cm = units::isq::si::cgs::unit_constants::cm;
|
||||
|
||||
auto d1 = 1. * si_cm; // si::length<si::centimetre>
|
||||
auto d2 = 1. * cgs_cm; // si::cgs::length<si::centimetre>
|
||||
@ -156,7 +156,7 @@ UDLs are helpful but they also have some disadvantages compared to Unit Constant
|
||||
|
||||
- UDLs::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
auto d1 = 123._q_km; // si::length<si::kilometre, long double>
|
||||
auto d2 = 123_q_km; // si::length<si::kilometre, std::int64_t>
|
||||
|
||||
@ -164,7 +164,7 @@ UDLs are helpful but they also have some disadvantages compared to Unit Constant
|
||||
|
||||
- Unit Constants::
|
||||
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
auto d1 = 123. * km; // si::length<si::kilometre, double>
|
||||
auto d2 = 123 * km; // si::length<si::kilometre, int>
|
||||
auto d3 = 123.f * km; // si::length<si::kilometre, float>
|
||||
@ -194,7 +194,7 @@ UDLs are helpful but they also have some disadvantages compared to Unit Constant
|
||||
The only issue we are aware of with Unit Constants is a potential problem of specifying
|
||||
a quantity in denominator::
|
||||
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
Speed auto v = 220 * km / 2 * h; // FAILS TO COMPILE (not a quantity of a speed dimension)
|
||||
|
||||
The above code can be fixed in one of the below ways:
|
||||
@ -220,7 +220,7 @@ In case the user does not care about the specific unit and representation but
|
||||
requires quantity of a concrete dimension than dimension-specific concepts can
|
||||
be used::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
constexpr Length auto d = 123_q_km; // si::length<si::kilometre, std::int64_t>
|
||||
|
||||
.. note::
|
||||
@ -235,8 +235,8 @@ assume that the user wants to implement an ``avg_speed`` function that will
|
||||
be calculating the average speed based on provided distance and duration
|
||||
quantities. The usage of such a function can look as follows::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::si::international::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::international::literals;
|
||||
constexpr Speed auto v1 = avg_speed(220_q_km, 2_q_h);
|
||||
constexpr Speed auto v2 = avg_speed(140_q_mi, 2_q_h);
|
||||
|
||||
|
@ -21,8 +21,8 @@ Output Streams
|
||||
The easiest way to print a quantity is to provide its object to the output
|
||||
stream::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::si::international::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::international::literals;
|
||||
constexpr Speed auto v1 = avg_speed(220._q_km, 2_q_h);
|
||||
constexpr Speed auto v2 = avg_speed(140._q_mi, 2_q_h);
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
|
@ -388,7 +388,7 @@ and user should not instantiate it by him/her-self. However the user can sometim
|
||||
observe this type in case an unit/dimension conversion expression will end up with an
|
||||
unknown/undefined unit type like in the below example::
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::isq::si::literals;
|
||||
|
||||
Length auto l = 100_q_km_per_h * 10_q_s;
|
||||
|
||||
|
@ -3,11 +3,11 @@ Quick Start
|
||||
|
||||
Here is a small example of possible operations::
|
||||
|
||||
#include <units/physical/si/area.h>
|
||||
#include <units/physical/si/frequency.h>
|
||||
#include <units/physical/si/speed.h>
|
||||
#include <units/isq/si/area.h>
|
||||
#include <units/isq/si/frequency.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
|
||||
using namespace units::physical::si;
|
||||
using namespace units::isq::si;
|
||||
|
||||
// simple numeric operations
|
||||
static_assert(10_q_km / 2 == 5_q_km);
|
||||
@ -38,12 +38,12 @@ performed without sacrificing on accuracy. Please see the below example for a qu
|
||||
of basic library features::
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/physical/si/speed.h>
|
||||
#include <units/physical/si/international/speed.h>
|
||||
#include <units/isq/si/speed.h>
|
||||
#include <units/isq/si/international/speed.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace units::physical;
|
||||
using namespace units::isq;
|
||||
|
||||
constexpr Speed auto avg_speed(Length auto d, Time auto t)
|
||||
{
|
||||
@ -52,8 +52,8 @@ of basic library features::
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::si::unit_constants;
|
||||
using namespace units::isq::si::literals;
|
||||
using namespace units::isq::si::unit_constants;
|
||||
|
||||
constexpr Speed auto v1 = 110 * km / h;
|
||||
constexpr Speed auto v2 = avg_speed(220_q_km, 2_q_h);
|
||||
|
@ -9,7 +9,7 @@ Systems
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
systems/physical
|
||||
systems/isq
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
@ -1,5 +1,5 @@
|
||||
Physical
|
||||
========
|
||||
International System of Quantities (ISQ)
|
||||
========================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
@ -1,5 +1,5 @@
|
||||
SI
|
||||
==
|
||||
International System of Units (SI)
|
||||
==================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
@ -6,7 +6,7 @@ Use Cases
|
||||
For brevity all the code examples in this chapter assume::
|
||||
|
||||
using namespace units;
|
||||
using namespace units::physical;
|
||||
using namespace units::isq;
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user