From 70bff31d061f6d0c834f0a258200a2ca13465bde Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 15 Apr 2021 19:13:25 +0200 Subject: [PATCH] feat: quantity aliases support addded --- docs/CHANGELOG.md | 1 + docs/Doxyfile.in | 3 +- example/CMakeLists.txt | 2 +- example/aliases/CMakeLists.txt | 51 +++ example/aliases/avg_speed.cpp | 197 ++++++++++ example/aliases/box_example.cpp | 105 +++++ .../capacitor_time_curve.cpp | 40 +- example/aliases/clcpp_response.cpp | 151 ++++++++ example/aliases/experimental_angle.cpp | 40 ++ example/aliases/foot_pound_second.cpp | 98 +++++ example/aliases/glide_computer_example.cpp | 202 ++++++++++ example/aliases/linear_algebra.cpp | 362 ++++++++++++++++++ example/aliases/measurement.cpp | 157 ++++++++ example/aliases/total_energy.cpp | 102 +++++ example/aliases/unknown_dimension.cpp | 72 ++++ example/alternative_namespaces/CMakeLists.txt | 35 -- example/alternative_namespaces/acceleration.h | 19 - example/alternative_namespaces/area.h | 14 - .../alternative_namespaces/box_example.cpp | 74 ---- .../alternative_namespaces/clcpp_response.cpp | 135 ------- .../conversion_factor.cpp | 63 --- example/alternative_namespaces/density.h | 19 - example/alternative_namespaces/force.h | 16 - example/alternative_namespaces/length.h | 88 ----- example/alternative_namespaces/mass.h | 19 - example/alternative_namespaces/time.h | 21 - example/alternative_namespaces/timer.cpp | 36 -- example/alternative_namespaces/timer.h | 64 ---- example/alternative_namespaces/units_str.h | 12 - example/alternative_namespaces/voltage.h | 31 -- example/alternative_namespaces/volume.h | 18 - example/hello_units.cpp | 30 +- example/literals/clcpp_response.cpp | 16 +- example/literals/total_energy.cpp | 11 +- example/references/clcpp_response.cpp | 55 +-- example/references/total_energy.cpp | 5 +- .../units/isq/iec80000/modulation_rate.h | 18 + .../units/isq/iec80000/storage_capacity.h | 46 +++ .../units/isq/iec80000/traffic_intensity.h | 10 + .../units/isq/iec80000/transfer_rate.h | 18 + .../include/units/isq/si/cgs/acceleration.h | 10 + .../si-cgs/include/units/isq/si/cgs/area.h | 10 + .../si-cgs/include/units/isq/si/cgs/energy.h | 10 + .../si-cgs/include/units/isq/si/cgs/force.h | 10 + .../si-cgs/include/units/isq/si/cgs/length.h | 10 + .../si-cgs/include/units/isq/si/cgs/mass.h | 10 + .../si-cgs/include/units/isq/si/cgs/power.h | 10 + .../include/units/isq/si/cgs/pressure.h | 10 + .../si-cgs/include/units/isq/si/cgs/speed.h | 10 + .../si-cgs/include/units/isq/si/cgs/time.h | 10 + .../include/units/isq/si/fps/acceleration.h | 10 + .../si-fps/include/units/isq/si/fps/area.h | 10 + .../si-fps/include/units/isq/si/fps/density.h | 10 + .../si-fps/include/units/isq/si/fps/energy.h | 11 + .../si-fps/include/units/isq/si/fps/force.h | 12 + .../si-fps/include/units/isq/si/fps/length.h | 19 + .../si-fps/include/units/isq/si/fps/mass.h | 18 + .../si-fps/include/units/isq/si/fps/power.h | 12 + .../include/units/isq/si/fps/pressure.h | 12 + .../si-fps/include/units/isq/si/fps/speed.h | 13 +- .../si-fps/include/units/isq/si/fps/time.h | 10 + .../si-fps/include/units/isq/si/fps/volume.h | 11 + .../si-iau/include/units/isq/si/iau/length.h | 12 + .../include/units/isq/si/imperial/length.h | 11 + .../include/units/isq/si/international/area.h | 10 + .../units/isq/si/international/length.h | 17 + .../units/isq/si/international/speed.h | 10 + .../units/isq/si/international/volume.h | 10 + .../include/units/isq/si/typographic/length.h | 13 + .../si-us/include/units/isq/si/us/length.h | 12 + .../si/include/units/isq/si/absorbed_dose.h | 30 ++ .../si/include/units/isq/si/acceleration.h | 10 + .../units/isq/si/amount_of_substance.h | 10 + .../include/units/isq/si/angular_velocity.h | 10 + src/systems/si/include/units/isq/si/area.h | 33 ++ .../si/include/units/isq/si/capacitance.h | 30 ++ .../include/units/isq/si/catalytic_activity.h | 33 +- .../si/include/units/isq/si/charge_density.h | 11 + .../si/include/units/isq/si/concentration.h | 9 + .../si/include/units/isq/si/conductance.h | 25 ++ .../si/include/units/isq/si/current_density.h | 10 + src/systems/si/include/units/isq/si/density.h | 10 + .../include/units/isq/si/dynamic_viscosity.h | 9 + .../si/include/units/isq/si/electric_charge.h | 10 + .../include/units/isq/si/electric_current.h | 30 ++ .../units/isq/si/electric_field_strength.h | 10 + src/systems/si/include/units/isq/si/energy.h | 29 ++ .../si/include/units/isq/si/energy_density.h | 10 + src/systems/si/include/units/isq/si/force.h | 30 ++ .../si/include/units/isq/si/frequency.h | 26 ++ .../si/include/units/isq/si/heat_capacity.h | 11 + .../si/include/units/isq/si/inductance.h | 26 ++ src/systems/si/include/units/isq/si/length.h | 31 ++ .../si/include/units/isq/si/luminance.h | 9 + .../include/units/isq/si/luminous_intensity.h | 30 ++ .../si/include/units/isq/si/magnetic_flux.h | 26 ++ .../include/units/isq/si/magnetic_induction.h | 29 +- src/systems/si/include/units/isq/si/mass.h | 54 +++ .../si/include/units/isq/si/molar_energy.h | 10 + .../si/include/units/isq/si/momentum.h | 10 + .../si/include/units/isq/si/permeability.h | 9 + .../si/include/units/isq/si/permittivity.h | 9 + src/systems/si/include/units/isq/si/power.h | 26 ++ .../si/include/units/isq/si/pressure.h | 30 ++ .../si/include/units/isq/si/radioactivity.h | 30 ++ .../si/include/units/isq/si/resistance.h | 26 ++ src/systems/si/include/units/isq/si/speed.h | 11 + .../si/include/units/isq/si/surface_tension.h | 10 + .../units/isq/si/thermal_conductivity.h | 10 + .../units/isq/si/thermodynamic_temperature.h | 10 + src/systems/si/include/units/isq/si/time.h | 21 + src/systems/si/include/units/isq/si/torque.h | 10 + src/systems/si/include/units/isq/si/voltage.h | 30 ++ src/systems/si/include/units/isq/si/volume.h | 53 +++ test/unit_test/runtime/CMakeLists.txt | 1 + test/unit_test/static/CMakeLists.txt | 2 + 116 files changed, 2956 insertions(+), 742 deletions(-) create mode 100644 example/aliases/CMakeLists.txt create mode 100644 example/aliases/avg_speed.cpp create mode 100644 example/aliases/box_example.cpp rename example/{alternative_namespaces => aliases}/capacitor_time_curve.cpp (59%) create mode 100644 example/aliases/clcpp_response.cpp create mode 100644 example/aliases/experimental_angle.cpp create mode 100644 example/aliases/foot_pound_second.cpp create mode 100644 example/aliases/glide_computer_example.cpp create mode 100644 example/aliases/linear_algebra.cpp create mode 100644 example/aliases/measurement.cpp create mode 100644 example/aliases/total_energy.cpp create mode 100644 example/aliases/unknown_dimension.cpp delete mode 100644 example/alternative_namespaces/CMakeLists.txt delete mode 100644 example/alternative_namespaces/acceleration.h delete mode 100644 example/alternative_namespaces/area.h delete mode 100644 example/alternative_namespaces/box_example.cpp delete mode 100644 example/alternative_namespaces/clcpp_response.cpp delete mode 100644 example/alternative_namespaces/conversion_factor.cpp delete mode 100644 example/alternative_namespaces/density.h delete mode 100644 example/alternative_namespaces/force.h delete mode 100644 example/alternative_namespaces/length.h delete mode 100644 example/alternative_namespaces/mass.h delete mode 100644 example/alternative_namespaces/time.h delete mode 100644 example/alternative_namespaces/timer.cpp delete mode 100644 example/alternative_namespaces/timer.h delete mode 100644 example/alternative_namespaces/units_str.h delete mode 100644 example/alternative_namespaces/voltage.h delete mode 100644 example/alternative_namespaces/volume.h diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ed039c12..da20f0cd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,7 @@ - refactor: `abs()` definition refactored to be more explicit about the return type - feat: quantity (point) kind support added (thanks [@johelegp](https://github.com/johelegp)) - feat: quantity references support added (thanks [@johelegp](https://github.com/johelegp)) + - feat: quantity aliases support addded - feat: interoperability with `std::chrono::duration` and other units libraries - feat: CTAD for dimensionless quantity added - feat: `modulation_rate` support added (thanks [@go2sh](https://github.com/go2sh)) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 72e86f3e..ce627992 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -101,4 +101,5 @@ QUIET = YES # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = UNITS_REFERENCES \ - UNITS_LITERALS + UNITS_LITERALS \ + UNITS_ALIASES diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 79d812be..d5571087 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -39,7 +39,7 @@ if(NOT UNITS_LIBCXX) add_subdirectory(glide_computer) endif() -add_subdirectory(alternative_namespaces) +add_subdirectory(aliases) add_subdirectory(kalman_filter) add_subdirectory(literals) add_subdirectory(references) diff --git a/example/aliases/CMakeLists.txt b/example/aliases/CMakeLists.txt new file mode 100644 index 00000000..f58760b2 --- /dev/null +++ b/example/aliases/CMakeLists.txt @@ -0,0 +1,51 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Mateusz Pusz +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_minimum_required(VERSION 3.2) + +# +# add_example(target ...) +# +function(add_example target) + add_executable(${target}-aliases ${target}.cpp) + target_link_libraries(${target}-aliases PRIVATE ${ARGN}) + target_compile_definitions(${target}-aliases PRIVATE UNITS_ALIASES) +endfunction() + +add_example(avg_speed mp-units::core-io mp-units::si mp-units::si-cgs mp-units::si-international) +add_example(box_example mp-units::core-fmt mp-units::si) +add_example(capacitor_time_curve mp-units::core-io mp-units::si) +add_example(clcpp_response mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-iau mp-units::si-imperial mp-units::si-international mp-units::si-typographic mp-units::si-us) +add_example(experimental_angle mp-units::core-fmt mp-units::core-io mp-units::si) +add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) +add_example(measurement mp-units::core-io mp-units::si) +add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) +add_example(unknown_dimension mp-units::core-io mp-units::si) + +if(NOT UNITS_LIBCXX) + add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) + target_compile_definitions(glide_computer_example-aliases PRIVATE UNITS_REFERENCES) + + find_package(linear_algebra CONFIG REQUIRED) + add_example(linear_algebra mp-units::core-fmt mp-units::core-io mp-units::si) + target_link_libraries(linear_algebra-aliases PRIVATE linear_algebra::linear_algebra) +endif() diff --git a/example/aliases/avg_speed.cpp b/example/aliases/avg_speed.cpp new file mode 100644 index 00000000..e9b2272b --- /dev/null +++ b/example/aliases/avg_speed.cpp @@ -0,0 +1,197 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include +#include +#include +#include +#include + +namespace { + +using namespace units::isq; + +constexpr si::speed +fixed_int_si_avg_speed(si::length d, + si::time t) +{ + return d / t; +} + +constexpr si::speed +fixed_double_si_avg_speed(si::length d, + si::time t) +{ + return d / t; +} + +template +constexpr Speed auto si_avg_speed(si::length d, + si::time t) +{ + return d / t; +} + +constexpr Speed auto avg_speed(Length auto d, Time auto t) +{ + return d / t; +} + +template +void print_result(D distance, T duration, V speed) +{ + const auto result_in_kmph = units::quantity_cast>(speed); + std::cout << "Average speed of a car that makes " << distance << " in " + << duration << " is " << result_in_kmph << ".\n"; +} + +void example() +{ + // SI (int) + { + using namespace units::aliases::isq::si; + constexpr auto distance = km(220); + constexpr auto duration = h(2); + + std::cout << "SI units with 'int' as representation\n"; + + print_result(distance, duration, fixed_int_si_avg_speed(distance, duration)); + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + print_result(distance, duration, si_avg_speed(distance, duration)); + print_result(distance, duration, avg_speed(distance, duration)); + } + + // SI (double) + { + using namespace units::aliases::isq::si; + constexpr auto distance = km(220.); + constexpr auto duration = h(2.); + + std::cout << "\nSI units with 'double' as representation\n"; + + // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed + print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), quantity_cast(duration))); + + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + print_result(distance, duration, si_avg_speed(distance, duration)); + print_result(distance, duration, avg_speed(distance, duration)); + } + + // Customary Units (int) + { + using namespace units::aliases::isq::si::international; + using namespace units::aliases::isq::si; + constexpr auto distance = mi(140); + constexpr auto duration = h(2); + + std::cout << "\nUS Customary Units with 'int' as representation\n"; + + // it is not possible to make a lossless conversion of miles to meters on an integral type + // (explicit cast needed) + print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), duration)); + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + print_result(distance, duration, si_avg_speed(distance, duration)); + print_result(distance, duration, avg_speed(distance, duration)); + } + + // Customary Units (double) + { + using namespace units::aliases::isq::si::international; + using namespace units::aliases::isq::si; + constexpr auto distance = mi(140.); + constexpr auto duration = h(2.); + + std::cout << "\nUS Customary Units with 'double' as representation\n"; + + // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed + // also it is not possible to make a lossless conversion of miles to meters on an integral type + // (explicit cast needed) + print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + print_result(distance, duration, si_avg_speed(distance, duration)); + print_result(distance, duration, avg_speed(distance, duration)); + } + + // CGS (int) + { + using namespace units::aliases::isq::si::cgs; + using namespace units::aliases::isq::si::time; + constexpr auto distance = cm(22'000'000); + constexpr auto duration = h(2); + + std::cout << "\nCGS units with 'int' as representation\n"; + + // it is not possible to make a lossless conversion of centimeters to meters on an integral type + // (explicit cast needed) + print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast(distance), duration)); + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + + // not possible to convert both a dimension and a unit with implicit cast + print_result(distance, duration, si_avg_speed(quantity_cast(distance), duration)); + + print_result(distance, duration, avg_speed(distance, duration)); + } + + // CGS (double) + { + using namespace units::aliases::isq::si::cgs; + using namespace units::aliases::isq::si::time; + constexpr auto distance = cm(22'000'000.); + constexpr auto duration = h(2.); + + std::cout << "\nCGS units with 'double' as representation\n"; + + // conversion from a floating-point to an integral type is a truncating one so an explicit cast is needed + // it is not possible to make a lossless conversion of centimeters to meters on an integral type + // (explicit cast needed) + print_result(distance, duration, fixed_int_si_avg_speed(quantity_cast>(distance), quantity_cast(duration))); + + print_result(distance, duration, fixed_double_si_avg_speed(distance, duration)); + + // not possible to convert both a dimension and a unit with implicit cast + print_result(distance, duration, si_avg_speed(quantity_cast(distance), duration)); + + print_result(distance, duration, avg_speed(distance, duration)); + } + +} + +} // namespace + +int main() +{ + try { + example(); + } + catch (const std::exception& ex) { + std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; + } + catch (...) { + std::cerr << "Unhandled unknown exception caught\n"; + } +} diff --git a/example/aliases/box_example.cpp b/example/aliases/box_example.cpp new file mode 100644 index 00000000..ad9443a5 --- /dev/null +++ b/example/aliases/box_example.cpp @@ -0,0 +1,105 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: keep +#include +#include +#include +#include +#include + +namespace { + +using namespace units::aliases::isq::si; + +inline constexpr auto g = units::isq::si::si2019::standard_gravity<>; +inline constexpr auto air_density = kg_per_m3<>(1.225); + +class Box { + area::m2<> base_; + length::m<> height_; + density::kg_per_m3<> density_ = air_density; +public: + constexpr Box(const length::m<>& length, const length::m<>& width, length::m<> height): base_(length * width), height_(std::move(height)) {} + + [[nodiscard]] constexpr force::N<> filled_weight() const + { + const volume::m3<> volume = base_ * height_; + const mass::kg<> mass = density_ * volume; + return mass * g; + } + + [[nodiscard]] constexpr length::m<> fill_level(const mass::kg<>& measured_mass) const + { + return height_ * measured_mass * g / filled_weight(); + } + + [[nodiscard]] constexpr volume::m3<> spare_capacity(const mass::kg<>& measured_mass) const + { + return (height_ - fill_level(measured_mass)) * base_; + } + + constexpr void set_contents_density(const density::kg_per_m3<>& density_in) + { + assert(density_in > air_density); + density_ = density_in; + } +}; + +} // namespace + + +int main() +{ + using namespace units; + using namespace units::isq; + + const length::m<> height(mm<>(200.0)); + auto box = Box(mm<>(1000.0), mm<>(500.0), height); + box.set_contents_density(kg_per_m3<>(1000.0)); + + const auto fill_time = s<>(200.0); // time since starting fill + const auto measured_mass = kg<>(20.0); // measured mass at fill_time + + const Length auto fill_level = box.fill_level(measured_mass); + const Dimensionless auto fill_percent = quantity_cast(fill_level / height); + const Volume auto spare_capacity = box.spare_capacity(measured_mass); + const auto input_flow_rate = measured_mass / fill_time; // unknown dimension + const Speed auto float_rise_rate = fill_level / fill_time; + const Time auto fill_time_left = (height / fill_level - 1) * fill_time; + + std::cout << "mp-units box example...\n"; + std::cout << fmt::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent); + std::cout << fmt::format("spare_capacity at {} = {}\n", fill_time, spare_capacity); + std::cout << fmt::format("input flow rate after {} = {}\n", fill_time, input_flow_rate); + std::cout << fmt::format("float rise rate = {}\n", float_rise_rate); + std::cout << fmt::format("box full E.T.A. at current flow rate = {}\n", fill_time_left); +} diff --git a/example/alternative_namespaces/capacitor_time_curve.cpp b/example/aliases/capacitor_time_curve.cpp similarity index 59% rename from example/alternative_namespaces/capacitor_time_curve.cpp rename to example/aliases/capacitor_time_curve.cpp index e5a7285d..707bed1f 100644 --- a/example/alternative_namespaces/capacitor_time_curve.cpp +++ b/example/aliases/capacitor_time_curve.cpp @@ -20,42 +20,44 @@ physical_quantities */ +#include +#include #include #include #include -#include +#include +#include // IWYU pragma: keep #include -#include "./voltage.h" #include -using namespace units::experimental; -using namespace units::isq::si::literals; - int main() { - std::cout << "mpusz/units capacitor time curve example...\n"; + using namespace units::isq; + using namespace units::aliases::isq::si; + + std::cout << "mp-units capacitor time curve example...\n"; std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); std::cout.precision(3); - constexpr auto C = 0.47_q_uF; - constexpr auto V0 = 5.0_q_V; - constexpr auto R = 4.7_q_kR; + constexpr auto C = capacitance::uF<>(0.47); + constexpr auto V0 = voltage::V<>(5.0); + constexpr auto R = resistance::kR<>(4.7); - for (auto t = 0_q_ms; t <= 50_q_ms; ++t) { - const auto Vt = V0 * units::exp(-t / (R * C)); + for (auto t = ms(0); t <= ms(50); ++t) { + const Voltage auto Vt = V0 * units::exp(-t / (R * C)); std::cout << "at " << t << " voltage is "; - if (Vt >= 1_q_V) + if (Vt >= V<>(1)) std::cout << Vt; - else if (Vt >= 1_q_mV) - std::cout << voltage::mV<>{Vt}; - else if (Vt >= 1_q_uV) - std::cout << voltage::uV<>{Vt}; - else if (Vt >= 1_q_nV) - std::cout << voltage::nV<>{Vt}; + else if (Vt >= mV<>(1)) + std::cout << mV<>(Vt); + else if (Vt >= uV<>(1)) + std::cout << uV<>(Vt); + else if (Vt >= nV<>(1)) + std::cout << nV<>(Vt); else - std::cout << voltage::pV<>{Vt}; + std::cout << pV<>(Vt); std::cout << "\n"; } } diff --git a/example/aliases/clcpp_response.cpp b/example/aliases/clcpp_response.cpp new file mode 100644 index 00000000..c098de96 --- /dev/null +++ b/example/aliases/clcpp_response.cpp @@ -0,0 +1,151 @@ +/* + Copyright (c) 2003-2019 Andy Little. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses./ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using namespace units; + +void simple_quantities() +{ + using namespace units::aliases::isq; + using namespace units::aliases::isq::si; + using namespace units::aliases::isq::si::international; + + using distance = si::length::m<>; + using duration = time::s<>; + + constexpr distance km = si::length::km<>(1.0); + constexpr distance miles = mi<>(1.0); + + constexpr duration sec = s<>(1); + constexpr duration min = time::min<>(1); + constexpr duration hr = h<>(1); + + std::cout << "A physical quantities library can choose the simple\n"; + std::cout << "option to provide output using a single type for each base unit:\n\n"; + std::cout << km << '\n'; + std::cout << miles << '\n'; + std::cout << sec << '\n'; + std::cout << min << '\n'; + std::cout << hr << "\n\n"; +} + +void quantities_with_typed_units() +{ + using namespace units::aliases::isq; + using namespace units::aliases::isq::si; + using namespace units::aliases::isq::si::international; + + constexpr si::length::km<> km = si::km<>(1.0); + constexpr si::international::length::mi<> miles = mi<>(1.0); + + std::cout.precision(6); + + constexpr time::s<> sec = s<>(1); + constexpr time::min<> min = si::min<>(1); + constexpr time::h<> hr = h<>(1); + + std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; + std::cout << km << '\n'; + std::cout << miles << '\n'; + std::cout << sec << '\n'; + std::cout << min << '\n'; + std::cout << hr << "\n\n"; + + constexpr si::length::m<> meter = m<>(1); + std::cout << "then a wide range of pre-defined units can be defined and converted,\n" + " for consistency and repeatability across applications:\n\n"; + + std::cout << meter << '\n'; + + std::cout << " = " << au<>(meter) << '\n'; + std::cout << " = " << iau::angstrom<>(meter) << '\n'; + std::cout << " = " << imperial::ch<>(meter) << '\n'; + std::cout << " = " << international::fathom<>(meter) << '\n'; + std::cout << " = " << quantity_cast(meter) << '\n'; // `us` system namespace collides with a microsecond (si::time::us) + std::cout << " = " << international::ft<>(meter) << '\n'; + std::cout << " = " << quantity_cast(meter) << '\n'; // `us` system namespace collides with a microsecond (si::time::us) + std::cout << " = " << international::in<>(meter) << '\n'; + std::cout << " = " << iau::ly<>(meter) << '\n'; + std::cout << " = " << international::mi<>(meter) << '\n'; + std::cout << " = " << international::mi_naut<>(meter) << '\n'; + std::cout << " = " << iau::pc<>(meter) << '\n'; + std::cout << " = " << typographic::pica_comp<>(meter) << '\n'; + std::cout << " = " << typographic::pica_prn<>(meter) << '\n'; + std::cout << " = " << typographic::point_comp<>(meter) << '\n'; + std::cout << " = " << typographic::point_prn<>(meter) << '\n'; + std::cout << " = " << imperial::rd<>(meter) << '\n'; + std::cout << " = " << international::yd<>(meter) << '\n'; +} + +void calcs_comparison() +{ + using namespace units::aliases::isq::si; + + std::cout << "\nA distinct unit for each type is efficient and accurate\n" + "when adding two values of the same very big\n" + "or very small type:\n\n"; + + length::fm L1A = fm<>(2.f); + length::fm L2A = fm<>(3.f); + length::fm LrA = L1A + L2A; + fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA); + + std::cout << "The single unit method must convert large\n" + "or small values in other units to the base unit.\n" + "This is both inefficient and inaccurate\n\n"; + + length::m L1B = L1A; + length::m L2B = L2A; + length::m LrB = L1B + L2B; + fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB); + + std::cout << "In multiplication and division:\n\n"; + + area::fm2 ArA = L1A * L2A; + fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA); + + std::cout << "similar problems arise\n\n"; + + area::m2 ArB = L1B * L2B; + fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB); +} + +} // namespace + +int main() +{ + std::cout << "This demo was originally posted on com.lang.c++.moderated in 2006\n"; + std::cout << "http://compgroups.net/comp.lang.c++.moderated/dimensional-analysis-units/51712\n"; + std::cout << "Here converted to use mp-units library.\n\n"; + + simple_quantities(); + quantities_with_typed_units(); + calcs_comparison(); +} diff --git a/example/aliases/experimental_angle.cpp b/example/aliases/experimental_angle.cpp new file mode 100644 index 00000000..0aa13a99 --- /dev/null +++ b/example/aliases/experimental_angle.cpp @@ -0,0 +1,40 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include +#include +#include + +int main() +{ + using namespace units::isq; + using namespace units::aliases::isq::si; + + const auto torque = N_m_per_rad<>(20.0); + const auto energy = J<>(20.0); + + units::Angle auto angle = energy / torque; + + std::cout << angle << '\n'; +} diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp new file mode 100644 index 00000000..ff5a6c28 --- /dev/null +++ b/example/aliases/foot_pound_second.cpp @@ -0,0 +1,98 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace units::aliases::isq; + +// Some basic specs for the warship +struct Ship { + si::fps::length::ft<> length; + si::fps::length::ft<> draft; + si::fps::length::ft<> beam; + + si::fps::speed::ft_per_s<> speed; + si::fps::mass::lb<> mass; + + si::fps::length::in<> mainGuns; + si::fps::mass::lb<> shellMass; + si::fps::speed::ft_per_s<> shellSpeed; + si::fps::power::ft_pdl_per_s<> power; +}; + +// Print 'a' in its current units and print its value cast to the units in each of Args +template +auto fmt_line(const Q a) +{ + return fmt::format("{:22}", a) + (fmt::format(",{:20}", units::quantity_cast(a)) + ...); +} + +// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI +void print_details(std::string_view description, const Ship& ship) +{ + const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4); + std::cout << fmt::format("{}\n", description); + std::cout << fmt::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) + << fmt::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) + << fmt::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) + << fmt::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) + << fmt::format("{:20} : {}\n", "speed", fmt_line, si::speed::km_per_h<>>(ship.speed)) + << fmt::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) + << fmt::format("{:20} : {}\n", "main guns", fmt_line, si::length::mm<>>(ship.mainGuns)) + << fmt::format("{:20} : {}\n", "fire shells weighing",fmt_line, si::mass::kg<>>(ship.shellMass)) + << fmt::format("{:20} : {}\n", "fire shells at",fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) + << fmt::format("{:20} : {}\n", "volume underwater", fmt_line, si::volume::l<>>(ship.mass / waterDensity)); +} + +int main() +{ + using namespace units::aliases::isq::si; + using namespace units::aliases::isq::si::fps; + using units::aliases::isq::si::fps::length::ft; // to disambiguate from si::femptotonne + + // KMS Bismark, using the units the Germans would use, taken from Wiki + auto bismark = Ship{.length{m<>(251.)}, .draft{m<>(9.3)}, .beam{m<>(36)}, .speed{km_per_h<>(56)}, .mass{t<>(50'300)}, .mainGuns{mm<>(380)}, .shellMass{kg<>(800)}, .shellSpeed{m_per_s<>(820.)}, .power{kW<>(110.45)}}; + + // USS Iowa, using units from the foot-pound-second system + auto iowa = Ship{.length{ft<>(860.)}, .draft{ft<>(37.) + in<>(2.)}, .beam{ft<>(108.) + in<>(2.)}, .speed{knot<>(33)}, .mass{lton<>(57'540)}, .mainGuns{in<>(16)}, .shellMass{lb<>(2700)}, .shellSpeed{ft_per_s<>(2690.)}, .power{hp<>(212'000)}}; + + // HMS King George V, using units from the foot-pound-second system + auto kgv = Ship{.length{ft<>(745.1)}, .draft{ft<>(33.) + in<>(7.5)}, .beam{ft<>(103.2) + in<>(2.5)}, .speed{knot<>(28.3)}, .mass{lton<>(42'245)}, .mainGuns{in<>(14)}, .shellMass{lb<>(1'590)}, .shellSpeed{ft_per_s<>(2483)}, .power{hp<>(110'000)}}; + + print_details("KMS Bismark, defined in appropriate units from the SI system", bismark); + std::cout << "\n\n"; + print_details("USS Iowa, defined in appropriate units foot-pound-second system", iowa); + std::cout << "\n\n"; + print_details("HMS King George V, defined in appropriate units foot-pound-second system", kgv); +} diff --git a/example/aliases/glide_computer_example.cpp b/example/aliases/glide_computer_example.cpp new file mode 100644 index 00000000..5644a55b --- /dev/null +++ b/example/aliases/glide_computer_example.cpp @@ -0,0 +1,202 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "glide_computer.h" +#include +#include +#include +#include + +UNITS_DIAGNOSTIC_PUSH +UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE +#include +UNITS_DIAGNOSTIC_POP + +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using namespace glide_computer; + +using namespace units::isq; + +auto get_gliders() +{ + using namespace units::aliases::isq::si; +UNITS_DIAGNOSTIC_PUSH +UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES + static const std::array gliders = { + glider{"SZD-30 Pirat", {velocity(km_per_h<>(83)), rate_of_climb(m_per_s<>(-0.7389))}}, + glider{"SZD-51 Junior", {velocity(km_per_h<>(80)), rate_of_climb(m_per_s<>(-0.6349))}}, + glider{"SZD-48 Jantar Std 3", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.77355))}}, + glider{"SZD-56 Diana", {velocity(km_per_h<>(110)), rate_of_climb(m_per_s<>(-0.63657))}}}; +UNITS_DIAGNOSTIC_POP + return gliders; +} + +auto get_weather_conditions() +{ + using namespace units::aliases::isq::si; + static const std::array weather_conditions = { + std::pair("Good", weather{height(m<>(1900)), rate_of_climb(m_per_s<>(4.3))}), + std::pair("Medium", weather{height(m<>(1550)), rate_of_climb(m_per_s<>(2.8))}), + std::pair("Bad", weather{height(m<>(850)), rate_of_climb(m_per_s<>(1.8))})}; + return weather_conditions; +} + +auto get_waypoints() +{ + using namespace geographic::literals; + using namespace units::aliases::isq::si::international; + static const std::array waypoints = { + waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude(ft<>(16))}, // N54°14'51.8" E18°40'28.2" + waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude(ft<>(115))} // N53°31'27.9" E18°50'58.1" + }; + return waypoints; +} + +template + requires std::same_as, glider> +void print(const R& gliders) +{ + std::cout << "Gliders:\n"; + std::cout << "========\n"; + for (const auto& g : gliders) { + std::cout << "- Name: " << g.name << "\n"; + std::cout << "- Polar:\n"; + for (const auto& p : g.polar) + fmt::print(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast(glide_ratio(g.polar[0]))); + std::cout << "\n"; + } +} + +template + requires std::same_as, std::pair> +void print(const R& conditions) +{ + std::cout << "Weather:\n"; + std::cout << "========\n"; + for (const auto& c : conditions) { + std::cout << "- " << c.first << "\n"; + const auto& w = c.second; + std::cout << " * Cloud base: " << fmt::format("{:%.0Q %q}", w.cloud_base) << " AGL\n"; + std::cout << " * Thermals strength: " << fmt::format("{:%.1Q %q}", w.thermal_strength) << "\n"; + std::cout << "\n"; + } +} + +template + requires std::same_as, waypoint> +void print(const R& waypoints) +{ + std::cout << "Waypoints:\n"; + std::cout << "==========\n"; + for (const auto& w : waypoints) + std::cout << fmt::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt); + std::cout << "\n"; +} + +void print(const task& t) +{ + std::cout << "Task:\n"; + std::cout << "=====\n"; + + std::cout << "- Start: " << t.get_start().name << "\n"; + std::cout << "- Finish: " << t.get_finish().name << "\n"; + std::cout << "- Length: " << fmt::format("{:%.1Q %q}", t.get_length()) << "\n"; + + std::cout << "- Legs: " << "\n"; + for (const auto& l : t.get_legs()) + std::cout << fmt::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); + std::cout << "\n"; +} + +void print(const safety& s) +{ + std::cout << "Safety:\n"; + std::cout << "=======\n"; + std::cout << "- Min AGL separation: " << fmt::format("{:%.0Q %q}", s.min_agl_height) << "\n"; + std::cout << "\n"; +} + +void print(const aircraft_tow& tow) +{ + std::cout << "Tow:\n"; + std::cout << "====\n"; + std::cout << "- Type: aircraft\n"; + std::cout << "- Height: " << fmt::format("{:%.0Q %q}", tow.height_agl) << "\n"; + std::cout << "- Performance: " << fmt::format("{:%.1Q %q}", tow.performance) << "\n"; + std::cout << "\n"; +} + +void example() +{ + using namespace units::aliases::isq::si; + + const safety sfty = {height(m<>(300))}; + const auto gliders = get_gliders(); + const auto waypoints = get_waypoints(); + const auto weather_conditions = get_weather_conditions(); + const task t = {waypoints[0], waypoints[1], waypoints[0]}; + const aircraft_tow tow = {height(m<>(400)), rate_of_climb(m_per_s<>(1.6))}; + // TODO use C++20 date library when available + // set `start_time` to 11:00 am today + const timestamp start_time(std::chrono::system_clock::now()); + + print(sfty); + print(gliders); + print(waypoints); + print(weather_conditions); + print(t); + print(tow); + + for (const auto& g : gliders) { + for (const auto& c : weather_conditions) { + std::string txt = "Scenario: Glider = " + g.name + ", Weather = " + c.first; + std::cout << txt << "\n"; + fmt::print("{0:=^{1}}\n\n", "", txt.size()); + + estimate(start_time, g, c.second, t, sfty, tow); + + std::cout << "\n\n"; + } + } +} + +} // namespace + +int main() +{ + try { + example(); + } catch (const std::exception& ex) { + std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; + } catch (...) { + std::cerr << "Unhandled unknown exception caught\n"; + } +} diff --git a/example/aliases/linear_algebra.cpp b/example/aliases/linear_algebra.cpp new file mode 100644 index 00000000..1414a768 --- /dev/null +++ b/example/aliases/linear_algebra.cpp @@ -0,0 +1,362 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include // IWYU pragma: keep +#include +#include +#include // IWYU pragma: keep +#include +#include +#include +#include + +namespace STD_LA { + +template +std::ostream& operator<<(std::ostream& os, const vector& v) +{ + os << "|"; + for (auto i = 0U; i < v.size(); ++i) { + os << fmt::format(" {:>9}", v(i)); + } + os << " |"; + return os; +} + +template +std::ostream& operator<<(std::ostream& os, const matrix& v) +{ + for (auto i = 0U; i < v.rows(); ++i) { + os << "|"; + for (auto j = 0U; j < v.columns(); ++j) { + os << fmt::format(" {:>9}", v(i, j)); + } + os << (i != v.rows() - 1U ? " |\n" : " |"); + } + return os; +} + +} // namespace STD_LA + +namespace { + +using namespace units::aliases::isq::si; + +template +using vector = std::math::fs_vector; + +template +using matrix = std::math::fs_matrix; + + +void vector_of_quantity_add() +{ + std::cout << "\nvector_of_quantity_add:\n"; + + vector> v = { m<>(1), m<>(2), m<>(3) }; + vector> u = { m<>(3), m<>(2), m<>(1) }; + vector> t = { km<>(3), km<>(2), km<>(1) }; + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + std::cout << "t = " << t << "\n"; + + std::cout << "v + u = " << v + u << "\n"; + std::cout << "v + t = " << v + t << "\n"; + std::cout << "t[m] = " << vector>(t) << "\n"; +} + +void vector_of_quantity_multiply_same() +{ + std::cout << "\nvector_of_quantity_multiply_same:\n"; + + vector> v = { m<>(1), m<>(2), m<>(3) }; + vector> u = { m<>(3), m<>(2), m<>(1) }; + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + + std::cout << "v * u = " << v * u << "\n"; + std::cout << "m<>(2) * v = " << m<>(2.) * v << "\n"; +} + +void vector_of_quantity_multiply_different() +{ + std::cout << "\nvector_of_quantity_multiply_different:\n"; + + vector> v = { N<>(1), N<>(2), N<>(3) }; + vector> u = { m<>(3), m<>(2), m<>(1) }; + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + + std::cout << "v * u = " << v * u << "\n"; + std::cout << "N<>(2) * u = " << N<>(2.) * u << "\n"; + std::cout << "2 * u = " << 2 * u << "\n"; +} + +void vector_of_quantity_divide_by_scalar() +{ + std::cout << "\nvector_of_quantity_divide_by_scalar:\n"; + + vector> v = { m<>(4), m<>(8), m<>(12) }; + + std::cout << "v = " << v << "\n"; + + // TODO Uncomment when bug in the LA is fixed + // std::cout << "v / s<>(2) = " << v / s<>(2) << "\n"; + // std::cout << "v / 2 = " << v / 2 << "\n"; +} + +void vector_of_quantity_tests() +{ + vector_of_quantity_add(); + vector_of_quantity_multiply_same(); + vector_of_quantity_multiply_different(); + vector_of_quantity_divide_by_scalar(); +} + +void matrix_of_quantity_add() +{ + std::cout << "\nmatrix_of_quantity_add:\n"; + + matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; + matrix> u = {{ m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }, { m<>(3), m<>(2), m<>(1) }}; + matrix> t = {{ mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }, { mm<>(3), mm<>(2), mm<>(1) }}; + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + std::cout << "t =\n" << t << "\n"; + + std::cout << "v + u =\n" << v + u << "\n"; + std::cout << "v + t =\n" << v + t << "\n"; + + // TODO Uncomment when fixed in the LA lib + // std::cout << "v[mm] =\n" << matrix>(v) << "\n"; +} + +void matrix_of_quantity_multiply_same() +{ + std::cout << "\nmatrix_of_quantity_multiply_same:\n"; + + matrix> v = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; + vector> u = { m<>(3), m<>(2), m<>(1) }; + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + + std::cout << "v * u =\n" << v * u << "\n"; + std::cout << "m<>(2) * u =\n" << m<>(2.) * u << "\n"; +} + +void matrix_of_quantity_multiply_different() +{ + std::cout << "\nmatrix_of_quantity_multiply_different:\n"; + + vector> v = { N<>(1), N<>(2), N<>(3) }; + matrix> u = {{ m<>(1), m<>(2), m<>(3) }, { m<>(4), m<>(5), m<>(6) }, { m<>(7), m<>(8), m<>(9) }}; + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + + std::cout << "v * u =\n" << v * u << "\n"; + std::cout << "N<>(2) * u =\n" << N<>(2.) * u << "\n"; + std::cout << "2 * u =\n" << 2 * u << "\n"; +} + +void matrix_of_quantity_divide_by_scalar() +{ + std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n"; + + matrix> v = {{ m<>(2), m<>(4), m<>(6) }, { m<>(4), m<>(6), m<>(8) }, { m<>(8), m<>(4), m<>(2) }}; + + std::cout << "v =\n" << v << "\n"; + + // TODO Uncomment when bug in the LA is fixed + // std::cout << "v / s<>(2) =\n" << v / s<>(2) << "\n"; + // std::cout << "v / 2 =\n" << v / 2 << "\n"; +} + +void matrix_of_quantity_tests() +{ + matrix_of_quantity_add(); + matrix_of_quantity_multiply_same(); + matrix_of_quantity_multiply_different(); + matrix_of_quantity_divide_by_scalar(); +} + +using namespace units::isq; + +template +using length_v = si::length>; + +template +using force_v = si::force>; + +void quantity_of_vector_add() +{ + std::cout << "\nquantity_of_vector_add:\n"; + + length_v<> v(vector<>{ 1, 2, 3 }); + length_v<> u(vector<>{ 3, 2, 1 }); + length_v t(vector<>{ 3, 2, 1 }); + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + std::cout << "t = " << t << "\n"; + + std::cout << "v + u = " << v + u << "\n"; + std::cout << "v + t = " << v + t << "\n"; + std::cout << "t[m] = " << quantity_cast(t) << "\n"; +} + +void quantity_of_vector_multiply_same() +{ + std::cout << "\nquantity_of_vector_multiply_same:\n"; + + length_v<> v(vector<>{ 1, 2, 3 }); + length_v<> u(vector<>{ 3, 2, 1 }); + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + + std::cout << "v * u = " << v * u << "\n"; + std::cout << "m<>(2) * v = " << m<>(2.) * v << "\n"; +} + +void quantity_of_vector_multiply_different() +{ + std::cout << "\nquantity_of_vector_multiply_different:\n"; + + force_v<> v(vector<>{ 1, 2, 3 }); + length_v<> u(vector<>{ 3, 2, 1 }); + + std::cout << "v = " << v << "\n"; + std::cout << "u = " << u << "\n"; + + std::cout << "v * u = " << v * u << "\n"; + std::cout << "N<>(2) * u = " << N<>(2.) * u << "\n"; + std::cout << "2 * u = " << 2 * u << "\n"; +} + +void quantity_of_vector_divide_by_scalar() +{ + std::cout << "\nquantity_of_vector_divide_by_scalar:\n"; + + length_v<> v(vector<>{ 4, 8, 12 }); + + std::cout << "v = " << v << "\n"; + + // TODO Uncomment when bug in the LA is fixed + // std::cout << "v / s<>(2) = " << v / s<>(2) << "\n"; + // std::cout << "v / 2 = " << v / 2 << "\n"; +} + +void quantity_of_vector_tests() +{ + quantity_of_vector_add(); + quantity_of_vector_multiply_same(); + quantity_of_vector_multiply_different(); + quantity_of_vector_divide_by_scalar(); +} + +template +using length_m = si::length>; + +void quantity_of_matrix_add() +{ + std::cout << "\nquantity_of_matrix_add:\n"; + + length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + length_m<> u(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + length_m t(matrix<>{{ 3, 2, 1 }, { 3, 2, 1 }, { 3, 2, 1 }}); + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + std::cout << "t =\n" << t << "\n"; + + std::cout << "v + u =\n" << v + u << "\n"; + std::cout << "v + t =\n" << v + t << "\n"; + + // TODO Uncomment when fixed in the LA lib + // std::cout << "v[mm] =\n" << matrix>(v) << "\n"; +} + +void quantity_of_matrix_multiply_same() +{ + std::cout << "\nquantity_of_matrix_multiply_same:\n"; + + length_m<> v(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + length_v<> u(vector<>{ 3, 2, 1 }); + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + + std::cout << "v * u =\n" << v * u << "\n"; + std::cout << "m<>(2) * u =\n" << m<>(2.) * u << "\n"; +} + +void quantity_of_matrix_multiply_different() +{ + std::cout << "\nquantity_of_matrix_multiply_different:\n"; + + force_v<> v(vector<>{ 1, 2, 3 }); + length_m<> u(matrix<>{{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}); + + std::cout << "v =\n" << v << "\n"; + std::cout << "u =\n" << u << "\n"; + + std::cout << "v * u =\n" << v * u << "\n"; + std::cout << "N<>(2) * u =\n" << N<>(2.) * u << "\n"; + std::cout << "2 * u =\n" << 2 * u << "\n"; +} + +void quantity_of_matrix_divide_by_scalar() +{ + std::cout << "\nquantity_of_matrix_divide_by_scalar:\n"; + + length_m<> v(matrix<>{{ 2, 4, 6 }, { 4, 6, 8 }, { 8, 4, 2 }}); + + std::cout << "v =\n" << v << "\n"; + + // TODO Uncomment when bug in the LA is fixed + // std::cout << "v / s<>(2) =\n" << v / s<>(2) << "\n"; + // std::cout << "v / 2 =\n" << v / 2 << "\n"; +} + +void quantity_of_matrix_tests() +{ + quantity_of_matrix_add(); + quantity_of_matrix_multiply_same(); + quantity_of_matrix_multiply_different(); + quantity_of_matrix_divide_by_scalar(); +} + +} // namespace + +int main() +{ + vector_of_quantity_tests(); + matrix_of_quantity_tests(); + quantity_of_vector_tests(); + quantity_of_matrix_tests(); +} diff --git a/example/aliases/measurement.cpp b/example/aliases/measurement.cpp new file mode 100644 index 00000000..ff91d62b --- /dev/null +++ b/example/aliases/measurement.cpp @@ -0,0 +1,157 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +template +class measurement { +public: + using value_type = T; + + measurement() = default; + + constexpr explicit measurement(const value_type& val, const value_type& err = {}) : + value_(val) + { + // it sucks that using declaration cannot be provided for a constructor initializer list + using namespace std; + uncertainty_ = abs(err); + } + + constexpr const value_type& value() const { return value_; } + constexpr const value_type& uncertainty() const { return uncertainty_; } + + constexpr value_type relative_uncertainty() const { return uncertainty() / value(); } + constexpr value_type lower_bound() const { return value() - uncertainty(); } + constexpr value_type upper_bound() const { return value() + uncertainty(); } + + [[nodiscard]] constexpr measurement operator-() const { return measurement(-value(), uncertainty()); } + + [[nodiscard]] friend constexpr measurement operator+(const measurement& lhs, const measurement& rhs) + { + using namespace std; + return measurement(lhs.value() + rhs.value(), hypot(lhs.uncertainty(), rhs.uncertainty())); + } + + [[nodiscard]] friend constexpr measurement operator-(const measurement& lhs, const measurement& rhs) + { + using namespace std; + return measurement(lhs.value() - rhs.value(), hypot(lhs.uncertainty(), rhs.uncertainty())); + } + + [[nodiscard]] friend constexpr measurement operator*(const measurement& lhs, const measurement& rhs) + { + const auto val = lhs.value() * rhs.value(); + using namespace std; + return measurement(val, val * hypot(lhs.relative_uncertainty(), rhs.relative_uncertainty())); + } + + [[nodiscard]] friend constexpr measurement operator*(const measurement& lhs, const value_type& value) + { + const auto val = lhs.value() * value; + return measurement(val, val * lhs.relative_uncertainty()); + } + + [[nodiscard]] friend constexpr measurement operator*(const value_type& value, const measurement& rhs) + { + const auto val = rhs.value() * value; + return measurement(val, val * rhs.relative_uncertainty()); + } + + [[nodiscard]] friend constexpr measurement operator/(const measurement& lhs, const measurement& rhs) + { + const auto val = lhs.value() / rhs.value(); + using namespace std; + return measurement(val, val * hypot(lhs.relative_uncertainty(), rhs.relative_uncertainty())); + } + + [[nodiscard]] friend constexpr measurement operator/(const measurement& lhs, const value_type& value) + { + const auto val = lhs.value() / value; + return measurement(val, val * lhs.relative_uncertainty()); + } + + [[nodiscard]] friend constexpr measurement operator/(const value_type& value, const measurement& rhs) + { + const auto val = value / rhs.value(); + return measurement(val, val * rhs.relative_uncertainty()); + } + + [[nodiscard]] constexpr auto operator<=>(const measurement&) const = default; + + friend std::ostream& operator<<(std::ostream& os, const measurement& v) + { + return os << v.value() << " ± " << v.uncertainty(); + } + +private: + value_type value_{}; + value_type uncertainty_{}; +}; + +} // namespace + + +namespace { + +static_assert(units::Representation>); + +void example() +{ + using namespace units::isq; + using namespace units::aliases::isq::si; + + const auto a = acceleration::m_per_s2>(measurement(9.8, 0.1)); + const auto t = time::s>(measurement(1.2, 0.1)); + + const Speed auto v1 = a * t; +#if UNITS_DOWNCAST_MODE == 0 + std::cout << a << " * " << t << " = " << v1 << " = " << km_per_h>(v1) << '\n'; +#else + std::cout << a << " * " << t << " = " << v1 << " = " << km_per_h>(v1) << '\n'; +#endif + + length::m> length(measurement(123., 1.)); + std::cout << "10 * " << length << " = " << 10 * length << '\n'; +} + +} // namespace + +int main() +{ + try { + example(); + } catch (const std::exception& ex) { + std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; + } catch (...) { + std::cerr << "Unhandled unknown exception caught\n"; + } +} diff --git a/example/aliases/total_energy.cpp b/example/aliases/total_energy.cpp new file mode 100644 index 00000000..693b47e4 --- /dev/null +++ b/example/aliases/total_energy.cpp @@ -0,0 +1,102 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include +#include +#include // IWYU pragma: keep +#include +#include +#include +#include +#include + +namespace { + +using namespace units::isq; + +Energy auto total_energy(Momentum auto p, Mass auto m, Speed auto c) +{ + return sqrt(pow<2>(p * c) + pow<2>(m * pow<2>(c))); +} + +void si_example() +{ + using namespace units::aliases::isq::si; + + constexpr Speed auto c = units::isq::si::si2019::speed_of_light<>; + + std::cout << "\n*** SI units (c = " << c << ") ***\n"; + + const Momentum auto p = GeV<>(4.) / c; + const Mass auto m = GeV<>(3.) / pow<2>(c); + const Energy auto E = total_energy(p, m, c); + + std::cout << "[in GeV]\n" + << "p = " << p << "\n" + << "m = " << m << "\n" + << "E = " << E << "\n"; + + const momentum::kg_m_per_s<> p_si = p; + const mass::kg<> m_si = m; + const energy::J<> E_si = total_energy(p_si, m_si, c); + + std::cout << "\n[in SI units]\n" + << "p = " << p_si << "\n" + << "m = " << m_si << "\n" + << "E = " << E_si << "\n"; + + std::cout << "\n[converted from SI units back to GeV]\n" + << "E = " << GeV<>(E_si) << "\n"; +} + +void natural_example() +{ + using namespace units::aliases::isq::natural; + + constexpr Speed auto c = units::isq::natural::speed_of_light<>; + const momentum::GeV<> p(4); + const mass::GeV<> m(3); + const Energy auto E = total_energy(p, m, c); + + std::cout << "\n*** Natural units (c = " << c << ") ***\n" + << "p = " << p << "\n" + << "m = " << m << "\n" + << "E = " << E << "\n"; +} + +} // namespace + +int main() +{ + try { + si_example(); + natural_example(); + } + catch (const std::exception& ex) { + std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; + } + catch (...) { + std::cerr << "Unhandled unknown exception caught\n"; + } +} diff --git a/example/aliases/unknown_dimension.cpp b/example/aliases/unknown_dimension.cpp new file mode 100644 index 00000000..42df205e --- /dev/null +++ b/example/aliases/unknown_dimension.cpp @@ -0,0 +1,72 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include // IWYU pragma: keep +#include +#include +#include +#include + +namespace { + +template +constexpr units::isq::Speed auto avg_speed(D d, T t) +{ + return d / t; +} + +void example() +{ + using namespace units::isq; + using namespace units::aliases::isq::si; + + Length auto d1 = m<>(123); + Time auto t1 = s<>(10); + Speed auto v1 = avg_speed(d1, t1); + + auto temp1 = v1 * m<>(50); // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' + Speed auto v2 = temp1 / m<>(100); // back to known dimensions again + Length auto d2 = v2 * s<>(60); + + std::cout << "d1 = " << d1 << '\n'; + std::cout << "t1 = " << t1 << '\n'; + std::cout << "v1 = " << v1 << '\n'; + std::cout << "temp1 = " << temp1 << '\n'; + std::cout << "v2 = " << v2 << '\n'; + std::cout << "d2 = " << d2 << '\n'; +} + +} // namespace + +int main() +{ + try { + example(); + } + catch (const std::exception& ex) { + std::cerr << "Unhandled std exception caught: " << ex.what() << '\n'; + } + catch (...) { + std::cerr << "Unhandled unknown exception caught\n"; + } +} diff --git a/example/alternative_namespaces/CMakeLists.txt b/example/alternative_namespaces/CMakeLists.txt deleted file mode 100644 index c20bca76..00000000 --- a/example/alternative_namespaces/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Mateusz Pusz -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 3.2) - -function(add_example target) - add_executable(${target}_alt ${target}.cpp) - target_link_libraries(${target}_alt PRIVATE mp-units::mp-units) - target_compile_definitions(${target}_alt PRIVATE UNITS_LITERALS) -endfunction() - -add_example(box_example mp-units::si) -add_example(capacitor_time_curve mp-units::si) -add_example(clcpp_response mp-units::si) -add_example(conversion_factor mp-units::si) -add_example(timer mp-units::si) diff --git a/example/alternative_namespaces/acceleration.h b/example/alternative_namespaces/acceleration.h deleted file mode 100644 index 4386d96e..00000000 --- a/example/alternative_namespaces/acceleration.h +++ /dev/null @@ -1,19 +0,0 @@ - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace acceleration { - -template -using m_per_s2 = units::isq::si::acceleration; - -template -constexpr m_per_s2 g{static_cast(9.80665)}; - -} // namespace acceleration - -}} // units::experimental diff --git a/example/alternative_namespaces/area.h b/example/alternative_namespaces/area.h deleted file mode 100644 index 5a813674..00000000 --- a/example/alternative_namespaces/area.h +++ /dev/null @@ -1,14 +0,0 @@ - -#pragma once - -#include - -namespace area { - -template -using m2 = units::isq::si::area; - -template -using fm2 = units::isq::si::area; - -} // namespace area diff --git a/example/alternative_namespaces/box_example.cpp b/example/alternative_namespaces/box_example.cpp deleted file mode 100644 index 06ae1aa1..00000000 --- a/example/alternative_namespaces/box_example.cpp +++ /dev/null @@ -1,74 +0,0 @@ - -#include -#include "./length.h" -#include "./acceleration.h" -#include "./density.h" -#include "./force.h" -#include "./mass.h" -#include "./time.h" -#include "./volume.h" - -#include - -using namespace units::experimental; - -struct Box { - - static constexpr auto air_density = density::kg_per_m3<>{1.225}; - - length::m<> length; - length::m<> width; - length::m<> height; - - constexpr Box(const length::m<>& l, const length::m<>& w, const length::m<>& h) : length{l}, width{w}, height{h} {} - - struct contents { - density::kg_per_m3<> density = air_density; - } contents; - - constexpr force::N<> filled_weight() const - { - const volume::m3<> volume = length * width * height; - const mass::kg<> mass = contents.density * volume; - return mass * acceleration::g<>; - } - - constexpr length::m<> fill_level(const mass::kg<>& measured_mass) const - { - return height * (measured_mass * acceleration::g<>) / filled_weight(); - } - - constexpr volume::m3<> spare_capacity(const mass::kg<>& measured_mass) const - { - return (height - fill_level(measured_mass)) * width * length; - } - - constexpr void set_contents_density(const density::kg_per_m3<>& density_in) - { - assert(density_in > air_density); - contents.density = density_in; - } - -}; - -#include - -using namespace units::isq::si::literals; - -int main() -{ - auto box = Box{1000.0_q_mm, 500.0_q_mm, 200.0_q_mm}; - box.set_contents_density(1000.0_q_kg_per_m3); - - auto fill_time = 200.0_q_s; // time since starting fill - auto measured_mass = 20.0_q_kg; // measured mass at fill_time - - std::cout << "mpusz/units box example ( using experimental alternative syntax for defining quantities) ...\n"; - std::cout << "fill height at " << fill_time << " = " << box.fill_level(measured_mass) << " (" - << (box.fill_level(measured_mass) / box.height) * 100 << "% full)\n"; - std::cout << "spare_capacity at " << fill_time << " = " << box.spare_capacity(measured_mass) << '\n'; - std::cout << "input flow rate after " << fill_time << " = " << measured_mass / fill_time << '\n'; - std::cout << "float rise rate = " << box.fill_level(measured_mass) / fill_time << '\n'; - auto fill_time_left = (box.height / box.fill_level(measured_mass) - 1) * fill_time; - std::cout << "box full E.T.A. at current flow rate = " << fill_time_left << '\n'; -} diff --git a/example/alternative_namespaces/clcpp_response.cpp b/example/alternative_namespaces/clcpp_response.cpp deleted file mode 100644 index 06f77d7c..00000000 --- a/example/alternative_namespaces/clcpp_response.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - Copyright (c) 2003-2019 Andy Little. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses./ -*/ - -#include -#include -#include - -#include "./length.h" -#include "./volume.h" -#include "./time.h" -#include "./area.h" -#include "./units_str.h" - -using namespace units::isq::si::literals; -using namespace units::isq::si::international; -using namespace units::experimental; - -void simple_quantities() -{ - using distance = length::m<>; - using q_time = q_time::s<>; - - constexpr distance km = 1.0_q_km; - constexpr distance miles = 1.0_q_mi; - - constexpr q_time sec = 1_q_s; - constexpr q_time min = 1_q_min; - constexpr q_time hr = 1_q_h; - - std::cout << "A physical quantities library can choose the simple\n"; - std::cout << "option to provide output using a single type for each base unit:\n\n"; - std::cout << km << '\n'; - std::cout << miles << '\n'; - std::cout << sec << '\n'; - std::cout << min << '\n'; - std::cout << hr << "\n\n"; -} - -void quantities_with_typed_units() -{ - constexpr length::km<> km = 1.0_q_km; - constexpr length::mi<> miles = 1.0_q_mi; - - constexpr q_time::s<> sec = 1_q_s; - constexpr q_time::min<> min = 1_q_min; - constexpr q_time::h<> hr = 1_q_h; - - std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; - std::cout << km << '\n'; - std::cout << miles << '\n'; - std::cout << sec << '\n'; - std::cout << min << '\n'; - std::cout << hr << "\n\n"; - - constexpr length::m<> meter = 1_q_m; - std::cout << "then a wide range of pre-defined units can be defined and converted,\n" - " for consistency and repeatability across applications:\n\n"; - - std::cout << meter << '\n'; - - std::cout << " = " << length::AU<>(meter) << '\n'; - std::cout << " = " << length::angstrom<>(meter) << '\n'; - std::cout << " = " << length::ch<>(meter) << '\n'; - std::cout << " = " << length::fathom<>(meter) << '\n'; - std::cout << " = " << length::fathom_us<>(meter) << '\n'; - std::cout << " = " << length::ft<>(meter) << '\n'; - std::cout << " = " << length::ft_us<>(meter) << '\n'; - std::cout << " = " << length::in<>(meter) << '\n'; - std::cout << " = " << length::ly<>(meter) << '\n'; - std::cout << " = " << length::mi<>(meter) << '\n'; - std::cout << " = " << length::mi_naut<>(meter) << '\n'; - std::cout << " = " << length::pc<>(meter) << '\n'; - std::cout << " = " << length::pica_comp<>(meter) << '\n'; - std::cout << " = " << length::pica_prn<>(meter) << '\n'; - std::cout << " = " << length::point_comp<>(meter) << '\n'; - std::cout << " = " << length::point_prn<>(meter) << '\n'; - std::cout << " = " << length::rd<>(meter) << '\n'; - std::cout << " = " << length::yd<>(meter) << '\n'; -} - -void calcs_comparison() -{ - std::cout << "\nA distinct unit for each type is efficient and accurate\n" - "when adding two values of the same very big\n" - "or very small type:\n\n"; - - length::fm L1A = 2._q_fm; - length::fm L2A = 3._q_fm; - length::fm LrA = L1A + L2A; - fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n",L1A,L2A,LrA); - - std::cout << "The single unit method must convert large\n" - "or small values in other units to the base unit.\n" - "This is both inefficient and inaccurate\n\n"; - - length::m L1B = L1A; - length::m L2B = L2A; - length::m LrB = L1B + L2B; - fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n",L1B,L2B,LrB); - - std::cout << "In multiplication and division:\n\n"; - - area::fm2 ArA = L1A * L2A; - fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n",L1A,L2A,ArA); - - std::cout << "similar problems arise\n\n"; - - area::m2 ArB = L1B * L2B; - fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n",L1B,L2B,ArB); -} - -int main() -{ - std::cout << "This demo was originally posted on comp.lang.c++.moderated in 2006\n"; - std::cout << "http://compgroups.net/comp.lang.c++.moderated/dimensional-analysis-units/51712\n"; - std::cout << "Here converted to use mpusz/units library.\n\n"; - - simple_quantities(); - quantities_with_typed_units(); - calcs_comparison(); -} diff --git a/example/alternative_namespaces/conversion_factor.cpp b/example/alternative_namespaces/conversion_factor.cpp deleted file mode 100644 index feec2aab..00000000 --- a/example/alternative_namespaces/conversion_factor.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (c) 2003-2020 Andy Little. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses./ -*/ - - -#include "./units_str.h" -#include "./length.h" -#include -#include - -/* - get conversion factor from one dimensionally equivalent - quantity type to another -*/ - -namespace { - -template - requires units::equivalent -inline constexpr std::common_type_t conversion_factor(Target, Source) -{ - // get quantities looking like inputs but with Q::rep that doesn't have narrowing conversion - typedef std::common_type_t rep; - typedef units::quantity source; - typedef units::quantity target; - return target{source{1}}.number(); -} - -} // namespace - -using namespace units::isq::si::literals; -using namespace units::experimental; - -int main() -{ - std::cout << "conversion factor in mpusz/units...\n\n"; - - constexpr length::m<> lengthA = 2.0_q_m; - constexpr length::mm<> lengthB = lengthA; - - std::cout << "lengthA( " << lengthA << " ) and lengthB( " << lengthB << " )\n" - << "represent the same length in different units.\n\n"; - - std::cout << "therefore ratio lengthA / lengthB == " << lengthA / lengthB << "\n\n"; - - std::cout << "conversion factor from lengthA::unit of " - << units_str(lengthA).standard() << " to lengthB::unit of " << units_str(lengthB).standard() << " :\n\n" - << "lengthB.number( " << lengthB.number() << " ) == lengthA.number( " << lengthA.number() - << " ) * conversion_factor( " << conversion_factor(lengthB, lengthA) << " )\n"; -} diff --git a/example/alternative_namespaces/density.h b/example/alternative_namespaces/density.h deleted file mode 100644 index 12a9dc78..00000000 --- a/example/alternative_namespaces/density.h +++ /dev/null @@ -1,19 +0,0 @@ - - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace density { - -template -using kg_per_m3 = units::isq::si::density; - -} - -}} // units::experimental - - diff --git a/example/alternative_namespaces/force.h b/example/alternative_namespaces/force.h deleted file mode 100644 index 346035d7..00000000 --- a/example/alternative_namespaces/force.h +++ /dev/null @@ -1,16 +0,0 @@ - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace force { - -template -using N = units::isq::si::force; - -} - -}} // units::experimental diff --git a/example/alternative_namespaces/length.h b/example/alternative_namespaces/length.h deleted file mode 100644 index 9d96dd60..00000000 --- a/example/alternative_namespaces/length.h +++ /dev/null @@ -1,88 +0,0 @@ - - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace units{ -namespace experimental{ - -namespace length { - -template -using m = units::isq::si::length; - -template -using mm = units::isq::si::length; - -template -using fm = units::isq::si::length; - -template -using km = units::isq::si::length; - -template -using AU = units::isq::si::length; - -template -using in = units::isq::si::length; - -template -using angstrom = units::isq::si::length; - -template -using ch = units::isq::si::length; - -template -using fathom = units::isq::si::length; - -template -using fathom_us = units::isq::si::length; - -template -using ft = units::isq::si::length; - -template -using ft_us = units::isq::si::length; - -template -using ly = units::isq::si::length; - -template -using mi = units::isq::si::length; - -template -using mi_naut = units::isq::si::length; - -template -using pc = units::isq::si::length; - -template -using pica_comp = units::isq::si::length; - -template -using pica_prn = units::isq::si::length; - -template -using point_comp = units::isq::si::length; - -template -using point_prn = units::isq::si::length; - -template -using rd = units::isq::si::length; - -template -using yd = units::isq::si::length; - - -} // namespace length - -}} // units::experimental - - diff --git a/example/alternative_namespaces/mass.h b/example/alternative_namespaces/mass.h deleted file mode 100644 index e8f4e60e..00000000 --- a/example/alternative_namespaces/mass.h +++ /dev/null @@ -1,19 +0,0 @@ - - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace mass { - -template -using kg = units::isq::si::mass; - -} - -}} // units::experimental - - diff --git a/example/alternative_namespaces/time.h b/example/alternative_namespaces/time.h deleted file mode 100644 index cd9cfa2d..00000000 --- a/example/alternative_namespaces/time.h +++ /dev/null @@ -1,21 +0,0 @@ - -#pragma once - -#include - -// named qtime due to conflict with time_t time(time_t*) -namespace q_time { - -template -using s = units::isq::si::time; - -template -using ms = units::isq::si::time; - -template -using min = units::isq::si::time; - -template -using h = units::isq::si::time; - -} // namespace time diff --git a/example/alternative_namespaces/timer.cpp b/example/alternative_namespaces/timer.cpp deleted file mode 100644 index c99848bd..00000000 --- a/example/alternative_namespaces/timer.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include -#include -#include "./timer.h" - -/* - simple timer, useful for perf timing etc -*/ - -using namespace units::experimental; -using namespace units::isq::si::literals; - -int main() -{ - std::cout << "Simple timer using mpusz/units ...\n"; - - auto const period = 0.5_q_s; - auto const duration = 10 * period; - - timer t; - - auto const start_time = t(); - - std::cout << "Started at " << start_time <<'\n'; - - auto prev = start_time; - for (auto now = t(); (now - start_time) < duration; now = t() ) { - if ( (now - prev ) >= period ){ - prev = now; - std::cout << "tick (" << now << ")\n";; - } - } - t.stop(); - - std::cout << "finished at " << t() << '\n'; -} diff --git a/example/alternative_namespaces/timer.h b/example/alternative_namespaces/timer.h deleted file mode 100644 index f76dda60..00000000 --- a/example/alternative_namespaces/timer.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -/* - Copyright (c) 2003-2020 Andy Little. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses./ - */ - -#include "./time.h" - -#include - -namespace units{ namespace experimental{ - - class timer{ - - public: - timer(): running(true) - { - start_time = std::clock(); - } - - void restart() - { - running = true; - start_time = std::clock(); - } - - void stop() - { - if (running){ - stop_time = std::clock(); - running = false; - } - } - - q_time::ms<> operator ()()const - { - std::clock_t const wanted = running ? std::clock() : stop_time; - static constexpr auto divider = 1000.0 / CLOCKS_PER_SEC; - - return q_time::ms<>( - static_cast(wanted - start_time) - ) * divider; - } - bool is_running() const {return running;} - bool is_stopped() const {return !running;} - private: - bool running; - std::clock_t start_time,stop_time; - }; - -} }//units::experimental diff --git a/example/alternative_namespaces/units_str.h b/example/alternative_namespaces/units_str.h deleted file mode 100644 index 76809c29..00000000 --- a/example/alternative_namespaces/units_str.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include -#include - -// get at the units text of the quantity, without its numeric value -inline auto constexpr units_str(const units::Quantity auto& q) -{ - typedef std::remove_cvref_t qtype; - return units::detail::unit_text(); -} diff --git a/example/alternative_namespaces/voltage.h b/example/alternative_namespaces/voltage.h deleted file mode 100644 index 3e772e6e..00000000 --- a/example/alternative_namespaces/voltage.h +++ /dev/null @@ -1,31 +0,0 @@ - - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace voltage { - -template -using V = units::isq::si::voltage; - -template -using mV = units::isq::si::voltage; - -template -using uV = units::isq::si::voltage; - -template -using nV = units::isq::si::voltage; - -template -using pV = units::isq::si::voltage; - -} // namespace voltage - -}} // units::experimental - - diff --git a/example/alternative_namespaces/volume.h b/example/alternative_namespaces/volume.h deleted file mode 100644 index 0729eee0..00000000 --- a/example/alternative_namespaces/volume.h +++ /dev/null @@ -1,18 +0,0 @@ - - -#pragma once - -#include - -namespace units{ -namespace experimental{ - -namespace volume { - -template -using m3 = units::isq::si::volume; - -} - -}} // units::experimental - diff --git a/example/hello_units.cpp b/example/hello_units.cpp index a72ee6049..f7b22988 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -20,8 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#define UNITS_REFERENCES +#define UNITS_ALIASES #define UNITS_LITERALS +#define UNITS_REFERENCES #include #include @@ -43,23 +44,26 @@ int main() { using namespace units::isq::si::literals; using namespace units::isq::si::references; + using namespace units::aliases::isq::si::international; constexpr Speed auto v1 = 110 * (km / h); - constexpr Speed auto v2 = avg_speed(220_q_km, 2_q_h); - constexpr Speed auto v3 = avg_speed(si::length(140), si::time(2)); + constexpr Speed auto v2 = mi_per_h<>(70.); + constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h); + constexpr Speed auto v4 = avg_speed(si::length(140), si::time(2)); #if UNITS_DOWNCAST_MODE == 0 - constexpr Speed auto v4 = quantity_cast>(v2); - constexpr Speed auto v5 = quantity_cast(v3); + constexpr Speed auto v5 = quantity_cast>(v3); + constexpr Speed auto v6 = quantity_cast(v4); #else - constexpr Speed auto v4 = quantity_cast>(v2); - constexpr Speed auto v5 = quantity_cast(v3); + constexpr Speed auto v5 = quantity_cast>(v3); + constexpr Speed auto v6 = quantity_cast(v4); #endif - constexpr Speed auto v6 = quantity_cast(v5); + constexpr Speed auto v7 = quantity_cast(v6); std::cout << v1 << '\n'; // 110 km/h - std::cout << fmt::format("{}", v2) << '\n'; // 110 km/h - std::cout << fmt::format("{:*^14}", v3) << '\n'; // ***70 mi/h**** - std::cout << fmt::format("{:%Q in %q}", v4) << '\n'; // 30.5556 in m/s - std::cout << fmt::format("{0:%Q} in {0:%q}", v5) << '\n'; // 31.2928 in m/s - std::cout << fmt::format("{:%Q}", v6) << '\n'; // 31 + std::cout << v2 << '\n'; // 70 mi/h + std::cout << fmt::format("{}", v3) << '\n'; // 110 km/h + std::cout << fmt::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** + std::cout << fmt::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s + std::cout << fmt::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s + std::cout << fmt::format("{:%Q}", v7) << '\n'; // 31 } diff --git a/example/literals/clcpp_response.cpp b/example/literals/clcpp_response.cpp index 6a130b2f..f0a3f013 100644 --- a/example/literals/clcpp_response.cpp +++ b/example/literals/clcpp_response.cpp @@ -111,28 +111,28 @@ void calcs_comparison() "when adding two values of the same very big\n" "or very small type:\n\n"; - length L1A = 2._q_fm; - length L2A = 3._q_fm; - length LrA = L1A + L2A; + const length L1A = 2._q_fm; + const length L2A = 3._q_fm; + const length LrA = L1A + L2A; fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA); std::cout << "The single unit method must convert large\n" "or small values in other units to the base unit.\n" "This is both inefficient and inaccurate\n\n"; - length L1B = L1A; - length L2B = L2A; - length LrB = L1B + L2B; + const length L1B = L1A; + const length L2B = L2A; + const length LrB = L1B + L2B; fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB); std::cout << "In multiplication and division:\n\n"; - area ArA = L1A * L2A; + const area ArA = L1A * L2A; fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA); std::cout << "similar problems arise\n\n"; - area ArB = L1B * L2B; + const area ArB = L1B * L2B; fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB); } diff --git a/example/literals/total_energy.cpp b/example/literals/total_energy.cpp index 7420f241..a81dd789 100644 --- a/example/literals/total_energy.cpp +++ b/example/literals/total_energy.cpp @@ -43,7 +43,6 @@ Energy auto total_energy(Momentum auto p, Mass auto m, Speed auto c) void si_example() { using namespace units::isq::si; - using GeV = gigaelectronvolt; constexpr Speed auto c = si2019::speed_of_light<>; @@ -68,17 +67,19 @@ void si_example() << "E = " << E_si << "\n"; std::cout << "\n[converted from SI units back to GeV]\n" - << "E = " << quantity_cast(E_si) << "\n"; + << "E = " << quantity_cast(E_si) << "\n"; } void natural_example() { using namespace units::isq::natural; - using GeV = gigaelectronvolt; + + // TODO Typical UDLs will not work here as the same units are reused by many quantities. + // Should we define some strange ones (i.e. _q_mass_GeV)? constexpr Speed auto c = speed_of_light<>; - const momentum p(4); - const mass m(3); + const momentum p(4); + const mass m(3); const Energy auto E = total_energy(p, m, c); std::cout << "\n*** Natural units (c = " << c << ") ***\n" diff --git a/example/references/clcpp_response.cpp b/example/references/clcpp_response.cpp index 704bbbb9..02e21c54 100644 --- a/example/references/clcpp_response.cpp +++ b/example/references/clcpp_response.cpp @@ -32,49 +32,52 @@ namespace { void simple_quantities() { using namespace units::isq; + using namespace units::isq::si; using namespace units::isq::si::references; using namespace units::isq::si::international::references; using distance = si::length; using duration = si::time; - constexpr distance kilometers = 1.0 * km; + constexpr distance km = 1.0 * references::km; constexpr distance miles = 1.0 * mi; - constexpr duration seconds = 1 * s; - constexpr duration minutes = 1 * min; - constexpr duration hours = 1 * h; + constexpr duration sec = 1 * s; + constexpr duration min = 1 * references::min; + constexpr duration hr = 1 * h; std::cout << "A physical quantities library can choose the simple\n"; std::cout << "option to provide output using a single type for each base unit:\n\n"; - std::cout << kilometers << '\n'; + std::cout << km << '\n'; std::cout << miles << '\n'; - std::cout << seconds << '\n'; - std::cout << minutes << '\n'; - std::cout << hours << "\n\n"; + std::cout << sec << '\n'; + std::cout << min << '\n'; + std::cout << hr << "\n\n"; } void quantities_with_typed_units() { using namespace units::isq; + using namespace units::isq::si; using namespace units::isq::si::references; + using namespace units::isq::si::international; using namespace units::isq::si::international::references; - constexpr auto kilometers = 1.0 * km; - constexpr auto miles = 1.0 * mi; + constexpr length km = 1.0 * si::references::km; + constexpr length miles = 1.0 * mi; std::cout.precision(6); - constexpr auto seconds = 1 * s; - constexpr auto minutes = 1 * min; - constexpr auto hours = 1 * h; + constexpr si::time sec = 1 * s; + constexpr si::time min = 1 * si::references::min; + constexpr si::time hr = 1 * h; std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; - std::cout << kilometers << '\n'; + std::cout << km << '\n'; std::cout << miles << '\n'; - std::cout << seconds << '\n'; - std::cout << minutes << '\n'; - std::cout << hours << "\n\n"; + std::cout << sec << '\n'; + std::cout << min << '\n'; + std::cout << hr << "\n\n"; constexpr auto meter = 1 * m; std::cout << "then a wide range of pre-defined units can be defined and converted,\n" @@ -104,35 +107,35 @@ void quantities_with_typed_units() void calcs_comparison() { - using namespace units::isq; + using namespace units::isq::si; using namespace units::isq::si::references; std::cout << "\nA distinct unit for each type is efficient and accurate\n" "when adding two values of the same very big\n" "or very small type:\n\n"; - const auto L1A = 2.f * fm; - const auto L2A = 3.f * fm; - const Length auto LrA = L1A + L2A; + const length L1A = 2.f * fm; + const length L2A = 3.f * fm; + const length LrA = L1A + L2A; fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA); std::cout << "The single unit method must convert large\n" "or small values in other units to the base unit.\n" "This is both inefficient and inaccurate\n\n"; - const auto L1B = quantity_cast(L1A); - const auto L2B = quantity_cast(L2A); - const Length auto LrB = L1B + L2B; + const length L1B = L1A; + const length L2B = L2A; + const length LrB = L1B + L2B; fmt::print("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB); std::cout << "In multiplication and division:\n\n"; - const Area auto ArA = L1A * L2A; + const area ArA = L1A * L2A; fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA); std::cout << "similar problems arise\n\n"; - const Area auto ArB = L1B * L2B; + const area ArB = L1B * L2B; fmt::print("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB); } diff --git a/example/references/total_energy.cpp b/example/references/total_energy.cpp index 71c72c9e..e6c911bf 100644 --- a/example/references/total_energy.cpp +++ b/example/references/total_energy.cpp @@ -74,10 +74,11 @@ void si_example() void natural_example() { using namespace units::isq::natural; + using namespace units::isq::natural::references; constexpr Speed auto c = speed_of_light<>; - const momentum p(4); - const mass m(3); + const auto p = 4. * momentum_references::GeV; + const auto m = 3. * mass_references::GeV; const Energy auto E = total_energy(p, m, c); std::cout << "\n*** Natural units (c = " << c << ") ***\n" diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h index dc01a6ed..c3b151cc 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h @@ -93,3 +93,21 @@ using namespace modulation_rate_references; #endif // UNITS_REFERENCES } // namespace units::isq::iec80000 + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::iec80000::inline modulation_rate { + +template using Bd = units::isq::iec80000::modulation_rate; +template using kBd = units::isq::iec80000::modulation_rate; +template using MBd = units::isq::iec80000::modulation_rate; +template using GBd = units::isq::iec80000::modulation_rate; +template using TBd = units::isq::iec80000::modulation_rate; +template using PBd = units::isq::iec80000::modulation_rate; +template using EBd = units::isq::iec80000::modulation_rate; +template using ZBd = units::isq::iec80000::modulation_rate; +template using YBd = units::isq::iec80000::modulation_rate; + +} // namespace units::aliases::isq::iec80000::inline modulation_rate + +#endif // UNITS_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h index 285ae84c..7a6e6cd5 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h @@ -178,3 +178,49 @@ using namespace storage_capacity_references; #endif // UNITS_REFERENCES } // namespace units::isq::iec80000 + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::iec80000::inline storage_capacity { + +// bits +template using bit = units::isq::iec80000::storage_capacity; + +template using kbit = units::isq::iec80000::storage_capacity; +template using Mbit = units::isq::iec80000::storage_capacity; +template using Gbit = units::isq::iec80000::storage_capacity; +template using Tbit = units::isq::iec80000::storage_capacity; +template using Pbit = units::isq::iec80000::storage_capacity; +template using Ebit = units::isq::iec80000::storage_capacity; +template using Zbit = units::isq::iec80000::storage_capacity; +template using Ybit = units::isq::iec80000::storage_capacity; + +template using Kibit = units::isq::iec80000::storage_capacity; +template using Mibit = units::isq::iec80000::storage_capacity; +template using Gibit = units::isq::iec80000::storage_capacity; +template using Tibit = units::isq::iec80000::storage_capacity; +template using Pibit = units::isq::iec80000::storage_capacity; +template using Eibit = units::isq::iec80000::storage_capacity; + +// bytes +template using B = units::isq::iec80000::storage_capacity; + +template using kB = units::isq::iec80000::storage_capacity; +template using MB = units::isq::iec80000::storage_capacity; +template using GB = units::isq::iec80000::storage_capacity; +template using TB = units::isq::iec80000::storage_capacity; +template using PB = units::isq::iec80000::storage_capacity; +template using EB = units::isq::iec80000::storage_capacity; +template using ZB = units::isq::iec80000::storage_capacity; +template using YB = units::isq::iec80000::storage_capacity; + +template using KiB = units::isq::iec80000::storage_capacity; +template using MiB = units::isq::iec80000::storage_capacity; +template using GiB = units::isq::iec80000::storage_capacity; +template using TiB = units::isq::iec80000::storage_capacity; +template using PiB = units::isq::iec80000::storage_capacity; +// template using EiB = units::isq::iec80000::storage_capacity; + +} // namespace units::aliases::isq::iec80000::inline storage_capacity + +#endif // UNITS_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h index 88dad8e5..541aa505 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h @@ -70,3 +70,13 @@ using namespace traffic_intensity_references; #endif // UNITS_REFERENCES } // namespace units::isq::iec80000 + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::iec80000::inline traffic_intensity { + +template using E = units::isq::iec80000::traffic_intensity; + +} // namespace units::aliases::isq::iec80000::inline traffic_intensity + +#endif // UNITS_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h index 56d70db9..29f4248a 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h @@ -71,3 +71,21 @@ constexpr auto operator"" _q_YB_per_s(unsigned long long l) { gsl_ExpectsAudit(s #endif // UNITS_LITERALS } // namespace units::isq::iec80000 + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::iec80000::inline transfer_rate { + +template using B_per_s = units::isq::iec80000::transfer_rate; +template using kB_per_s = units::isq::iec80000::transfer_rate; +template using MB_per_s = units::isq::iec80000::transfer_rate; +template using GB_per_s = units::isq::iec80000::transfer_rate; +template using TB_per_s = units::isq::iec80000::transfer_rate; +template using PB_per_s = units::isq::iec80000::transfer_rate; +template using EB_per_s = units::isq::iec80000::transfer_rate; +template using ZB_per_s = units::isq::iec80000::transfer_rate; +template using YB_per_s = units::isq::iec80000::transfer_rate; + +} // namespace units::aliases::isq::iec80000::inline transfer_rate + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h b/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h index a66213de..fd349032 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h @@ -69,3 +69,13 @@ using namespace acceleration_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline acceleration { + +template using Gal = units::isq::si::cgs::acceleration; + +} // namespace units::aliases::isq::si::cgs::inline acceleration + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/area.h b/src/systems/si-cgs/include/units/isq/si/cgs/area.h index 89361609..5f0f1495 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/area.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/area.h @@ -71,3 +71,13 @@ using namespace area_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline area { + +template using cm2 = units::isq::si::cgs::area; + +} // namespace units::aliases::isq::si::cgs::inline area + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/energy.h b/src/systems/si-cgs/include/units/isq/si/cgs/energy.h index 5abcebe5..6f2bd643 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/energy.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/energy.h @@ -71,3 +71,13 @@ using namespace energy_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline energy { + +template using erg = units::isq::si::cgs::energy; + +} // namespace units::aliases::isq::si::cgs::inline energy + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/force.h b/src/systems/si-cgs/include/units/isq/si/cgs/force.h index 579ea978..3fd4ae1e 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/force.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/force.h @@ -72,3 +72,13 @@ using namespace force_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline force { + +template using dyn = units::isq::si::cgs::force; + +} // namespace units::aliases::isq::si::cgs::inline force + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/length.h b/src/systems/si-cgs/include/units/isq/si/cgs/length.h index 996d82c0..2ac6392f 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/length.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/length.h @@ -70,3 +70,13 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline length { + +template using cm = units::isq::si::cgs::length; + +} // namespace units::aliases::isq::si::cgs::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/mass.h b/src/systems/si-cgs/include/units/isq/si/cgs/mass.h index 6c4012f5..e8a5ca94 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/mass.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/mass.h @@ -70,3 +70,13 @@ using namespace mass_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline mass { + +template using g = units::isq::si::cgs::mass; + +} // namespace units::aliases::isq::si::cgs::inline mass + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/power.h b/src/systems/si-cgs/include/units/isq/si/cgs/power.h index 5b35c923..cd730ac0 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/power.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/power.h @@ -54,3 +54,13 @@ constexpr auto operator"" _q_erg_per_s(long double l) { return power using erg_per_s = units::isq::si::cgs::power; + +} // namespace units::aliases::isq::si::cgs::inline power + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h b/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h index 7c43811c..d10ec70c 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h @@ -72,3 +72,13 @@ using namespace pressure_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline pressure { + +template using Ba = units::isq::si::cgs::pressure; + +} // namespace units::aliases::isq::si::cgs::inline pressure + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/speed.h b/src/systems/si-cgs/include/units/isq/si/cgs/speed.h index 508634bf..0081b159 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/speed.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/speed.h @@ -53,3 +53,13 @@ constexpr auto operator"" _q_cm_per_s(long double l) { return speed using cm_per_s = units::isq::si::cgs::speed; + +} // namespace units::aliases::isq::si::cgs::inline speed + +#endif // UNITS_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/time.h b/src/systems/si-cgs/include/units/isq/si/cgs/time.h index aea13655..b3b0c1c4 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/time.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/time.h @@ -64,3 +64,13 @@ using namespace time_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::cgs + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::cgs::inline time { + +using namespace units::aliases::isq::si::time; + +} // namespace units::aliases::isq::si::cgs::inline time + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h index 22520304..e6587f58 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/acceleration.h +++ b/src/systems/si-fps/include/units/isq/si/fps/acceleration.h @@ -52,3 +52,13 @@ constexpr auto operator"" _q_ft_per_s2(long double l) { return acceleration using ft_per_s2 = units::isq::si::fps::acceleration; + +} // namespace units::aliases::isq::si::fps::inline acceleration + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/area.h b/src/systems/si-fps/include/units/isq/si/fps/area.h index 7836e291..2f967eb2 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/area.h +++ b/src/systems/si-fps/include/units/isq/si/fps/area.h @@ -70,3 +70,13 @@ using namespace area_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline area { + +template using ft2 = units::isq::si::fps::area; + +} // namespace units::aliases::isq::si::fps::inlipne area + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/density.h b/src/systems/si-fps/include/units/isq/si/fps/density.h index 717906de..88910419 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/density.h +++ b/src/systems/si-fps/include/units/isq/si/fps/density.h @@ -54,3 +54,13 @@ constexpr auto operator"" _q_lb_per_ft3(long double l) { return density using lb_per_ft3 = units::isq::si::fps::density; + +} // namespace units::aliases::isq::si::fps::inline density + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/energy.h b/src/systems/si-fps/include/units/isq/si/fps/energy.h index b5601bc4..1f559b75 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/energy.h +++ b/src/systems/si-fps/include/units/isq/si/fps/energy.h @@ -62,3 +62,14 @@ constexpr auto operator"" _q_ft_lbf(long double l) { return energy using ft_pdl = units::isq::si::fps::energy; +template using ft_lbf = units::isq::si::fps::energy; + +} // namespace units::aliases::isq::si::fps::inline energy + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/force.h b/src/systems/si-fps/include/units/isq/si/fps/force.h index 25128e60..43efd300 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/force.h +++ b/src/systems/si-fps/include/units/isq/si/fps/force.h @@ -91,3 +91,15 @@ using namespace force_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline force { + +template using pdl = units::isq::si::fps::force; +template using lbf = units::isq::si::fps::force; +template using klbf = units::isq::si::fps::force; + +} // namespace units::aliases::isq::si::fps::inline force + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/length.h b/src/systems/si-fps/include/units/isq/si/fps/length.h index a9ac37ff..0c8345c0 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/length.h +++ b/src/systems/si-fps/include/units/isq/si/fps/length.h @@ -128,3 +128,22 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline length { + +template using thou = units::isq::si::fps::length; +template using mil = thou; + +template using in = units::isq::si::fps::length; +template using ft = units::isq::si::fps::length; +template using yd = units::isq::si::fps::length; +template using ftm = units::isq::si::fps::length; +template using kyd = units::isq::si::fps::length; +template using mile = units::isq::si::fps::length; +template using naut_mi = units::isq::si::fps::length; + +} // namespace units::aliases::isq::si::fps::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/mass.h b/src/systems/si-fps/include/units/isq/si/fps/mass.h index 26535de3..8471c127 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/mass.h +++ b/src/systems/si-fps/include/units/isq/si/fps/mass.h @@ -127,3 +127,21 @@ using namespace mass_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline mass { + +template using gr = units::isq::si::fps::mass; +template using dr = units::isq::si::fps::mass; +template using oz = units::isq::si::fps::mass; +template using lb = units::isq::si::fps::mass; +template using st = units::isq::si::fps::mass; +template using qr = units::isq::si::fps::mass; +template using cwt = units::isq::si::fps::mass; +template using ston = units::isq::si::fps::mass; +template using lton = units::isq::si::fps::mass; + +} // namespace units::aliases::isq::si::fps::inline mass + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/power.h b/src/systems/si-fps/include/units/isq/si/fps/power.h index 4b3d2458..fa972dfc 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/power.h +++ b/src/systems/si-fps/include/units/isq/si/fps/power.h @@ -83,3 +83,15 @@ using namespace power_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline power { + +template using ft_pdl_per_s = units::isq::si::fps::power; +template using ft_lbf_per_s = units::isq::si::fps::power; +template using hp = units::isq::si::fps::power; + +} // namespace units::aliases::isq::si::fps::inline power + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/pressure.h b/src/systems/si-fps/include/units/isq/si/fps/pressure.h index 8cd40b35..ef91e88a 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/pressure.h +++ b/src/systems/si-fps/include/units/isq/si/fps/pressure.h @@ -87,3 +87,15 @@ using namespace pressure_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline pressure { + +template using pdl_per_ft2 = units::isq::si::fps::pressure; +template using psi = units::isq::si::fps::pressure; +template using kpsi = units::isq::si::fps::pressure; + +} // namespace units::aliases::isq::si::fps::inline pressure + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/speed.h b/src/systems/si-fps/include/units/isq/si/fps/speed.h index f36eb017..16ac98e5 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/speed.h +++ b/src/systems/si-fps/include/units/isq/si/fps/speed.h @@ -47,7 +47,6 @@ struct nautical_mile_per_hour : named_deduced_unit {}; - #ifdef UNITS_LITERALS inline namespace literals { @@ -86,3 +85,15 @@ using namespace speed_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline speed { + +template using ft_per_s = units::isq::si::fps::speed; +template using mph = units::isq::si::fps::speed; +template using knot = units::isq::si::fps::speed; + +} // namespace units::aliases::isq::si::fps::inline speed + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/time.h b/src/systems/si-fps/include/units/isq/si/fps/time.h index d4f9d4cf..9162358e 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/time.h +++ b/src/systems/si-fps/include/units/isq/si/fps/time.h @@ -68,3 +68,13 @@ using namespace time_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline time { + +using namespace units::aliases::isq::si::time; + +} // namespace units::aliases::isq::si::fps::inline time + +#endif // UNITS_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/volume.h b/src/systems/si-fps/include/units/isq/si/fps/volume.h index f9d91ba1..e86053c2 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/volume.h +++ b/src/systems/si-fps/include/units/isq/si/fps/volume.h @@ -76,3 +76,14 @@ using namespace volume_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::fps + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::fps::inline volume { + +template using ft3 = units::isq::si::fps::volume; +template using yd3 = units::isq::si::fps::volume; + +} // namespace units::aliases::isq::si::fps::inline volume + +#endif // UNITS_ALIASES diff --git a/src/systems/si-iau/include/units/isq/si/iau/length.h b/src/systems/si-iau/include/units/isq/si/iau/length.h index cfe16dde..0587a633 100644 --- a/src/systems/si-iau/include/units/isq/si/iau/length.h +++ b/src/systems/si-iau/include/units/isq/si/iau/length.h @@ -83,3 +83,15 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::iau + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::iau::inline length { + +template using ly = units::isq::si::length; +template using pc = units::isq::si::length; +template using angstrom = units::isq::si::length; + +} // namespace units::aliases::isq::si::iau + +#endif // UNITS_ALIASES diff --git a/src/systems/si-imperial/include/units/isq/si/imperial/length.h b/src/systems/si-imperial/include/units/isq/si/imperial/length.h index 8af5ad1e..4229f386 100644 --- a/src/systems/si-imperial/include/units/isq/si/imperial/length.h +++ b/src/systems/si-imperial/include/units/isq/si/imperial/length.h @@ -74,3 +74,14 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::imperial + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::imperial::inline length { + +template using ch = units::isq::si::length; +template using rd = units::isq::si::length; + +} // namespace units::aliases::isq::si::imperial::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/area.h b/src/systems/si-international/include/units/isq/si/international/area.h index 05d7b17f..18e8399e 100644 --- a/src/systems/si-international/include/units/isq/si/international/area.h +++ b/src/systems/si-international/include/units/isq/si/international/area.h @@ -66,3 +66,13 @@ using namespace area_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::international + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::international::inline area { + +template using ft2 = units::isq::si::area; + +} // namespace units::aliases::isq::si::international::inline area + +#endif // UNITS_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/length.h b/src/systems/si-international/include/units/isq/si/international/length.h index 4607f008..d9e51fe6 100644 --- a/src/systems/si-international/include/units/isq/si/international/length.h +++ b/src/systems/si-international/include/units/isq/si/international/length.h @@ -130,3 +130,20 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::international + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::international::inline length { + +template using yd = units::isq::si::length; +template using ft = units::isq::si::length; +template using fathom = units::isq::si::length; +template using in = units::isq::si::length; +template using mi = units::isq::si::length; +template using mi_naut = units::isq::si::length; +template using thou = units::isq::si::length; +template using mil = units::isq::si::length; + +} // namespace units::aliases::isq::si::international::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/speed.h b/src/systems/si-international/include/units/isq/si/international/speed.h index a8d3b5b3..c091ca55 100644 --- a/src/systems/si-international/include/units/isq/si/international/speed.h +++ b/src/systems/si-international/include/units/isq/si/international/speed.h @@ -49,3 +49,13 @@ constexpr auto operator"" _q_mi_per_h(long double l) { return si::speed using mi_per_h = units::isq::si::speed; + +} // namespace units::aliases::isq::si::international::inline speed + +#endif // UNITS_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/volume.h b/src/systems/si-international/include/units/isq/si/international/volume.h index 9e03d521..aea22c32 100644 --- a/src/systems/si-international/include/units/isq/si/international/volume.h +++ b/src/systems/si-international/include/units/isq/si/international/volume.h @@ -66,3 +66,13 @@ using namespace volume_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::international + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::international::inline volume { + +template using ft3 = units::isq::si::volume; + +} // namespace units::aliases::isq::si::international::inline volume + +#endif // UNITS_ALIASES diff --git a/src/systems/si-typographic/include/units/isq/si/typographic/length.h b/src/systems/si-typographic/include/units/isq/si/typographic/length.h index 17467cec..98f20dd5 100644 --- a/src/systems/si-typographic/include/units/isq/si/typographic/length.h +++ b/src/systems/si-typographic/include/units/isq/si/typographic/length.h @@ -85,3 +85,16 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::typographic + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::typographic::inline length { + +template using pica_comp = units::isq::si::length; +template using pica_prn = units::isq::si::length; +template using point_comp = units::isq::si::length; +template using point_prn = units::isq::si::length; + +} // namespace units::aliases::isq::si::typographic::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si-us/include/units/isq/si/us/length.h b/src/systems/si-us/include/units/isq/si/us/length.h index b115dac6..1204e58d 100644 --- a/src/systems/si-us/include/units/isq/si/us/length.h +++ b/src/systems/si-us/include/units/isq/si/us/length.h @@ -84,3 +84,15 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si::us + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::us::inline length { + +template using ft = units::isq::si::length; +template using fathom = units::isq::si::length; +template using mi = units::isq::si::length; + +} // namespace units::aliases::isq::si::us::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/absorbed_dose.h b/src/systems/si/include/units/isq/si/absorbed_dose.h index d2d7e015..b1f63e4f 100644 --- a/src/systems/si/include/units/isq/si/absorbed_dose.h +++ b/src/systems/si/include/units/isq/si/absorbed_dose.h @@ -191,3 +191,33 @@ using namespace absorbed_dose_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline absorbed_dose { + +template using Gy = units::isq::si::absorbed_dose; +template using yGy = units::isq::si::absorbed_dose; +template using zGy = units::isq::si::absorbed_dose; +template using aGy = units::isq::si::absorbed_dose; +template using fGy = units::isq::si::absorbed_dose; +template using pGy = units::isq::si::absorbed_dose; +template using nGy = units::isq::si::absorbed_dose; +template using uGy = units::isq::si::absorbed_dose; +template using mGy = units::isq::si::absorbed_dose; +template using cGy = units::isq::si::absorbed_dose; +template using dGy = units::isq::si::absorbed_dose; +template using daGy = units::isq::si::absorbed_dose; +template using hGy = units::isq::si::absorbed_dose; +template using kGy = units::isq::si::absorbed_dose; +template using MGy = units::isq::si::absorbed_dose; +template using GGy = units::isq::si::absorbed_dose; +template using TGy = units::isq::si::absorbed_dose; +template using PGy = units::isq::si::absorbed_dose; +template using EGy = units::isq::si::absorbed_dose; +template using ZGy = units::isq::si::absorbed_dose; +template using YGy = units::isq::si::absorbed_dose; + +} // namespace units::aliases::isq::si::inline absorbed_dose + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/acceleration.h b/src/systems/si/include/units/isq/si/acceleration.h index 1816b125..8cfa0331 100644 --- a/src/systems/si/include/units/isq/si/acceleration.h +++ b/src/systems/si/include/units/isq/si/acceleration.h @@ -52,3 +52,13 @@ constexpr auto operator"" _q_m_per_s2(long double l) { return acceleration using m_per_s2 = units::isq::si::acceleration; + +} // namespace units::aliases::isq::si::inline acceleration + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/amount_of_substance.h b/src/systems/si/include/units/isq/si/amount_of_substance.h index 433c4f6b..b1e074a1 100644 --- a/src/systems/si/include/units/isq/si/amount_of_substance.h +++ b/src/systems/si/include/units/isq/si/amount_of_substance.h @@ -70,3 +70,13 @@ using namespace amount_of_substance_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline amount_of_substance { + +template using mol = units::isq::si::amount_of_substance; + +} // namespace units::aliases::isq::si::inline amount_of_substance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/angular_velocity.h b/src/systems/si/include/units/isq/si/angular_velocity.h index 5ed59bf3..316708b9 100644 --- a/src/systems/si/include/units/isq/si/angular_velocity.h +++ b/src/systems/si/include/units/isq/si/angular_velocity.h @@ -54,3 +54,13 @@ constexpr auto operator"" _q_rad_per_s(long double l) { return angular_velocity< #endif // UNITS_LITERALS } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline angular_velocity { + +template using rad_per_s = units::isq::si::angular_velocity; + +} // namespace units::aliases::isq::si::inline angular_velocity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/area.h b/src/systems/si/include/units/isq/si/area.h index ed77183d..3ffb5744 100644 --- a/src/systems/si/include/units/isq/si/area.h +++ b/src/systems/si/include/units/isq/si/area.h @@ -184,6 +184,7 @@ inline constexpr auto Pm2 = reference{}; inline constexpr auto Em2 = reference{}; inline constexpr auto Zm2 = reference{}; inline constexpr auto Ym2 = reference{}; + inline constexpr auto ha = reference{}; } // namespace area_references @@ -197,3 +198,35 @@ using namespace area_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline area { + +template using m2 = units::isq::si::area; +template using ym2 = units::isq::si::area; +template using zm2 = units::isq::si::area; +template using am2 = units::isq::si::area; +template using fm2 = units::isq::si::area; +template using pm2 = units::isq::si::area; +template using nm2 = units::isq::si::area; +template using um2 = units::isq::si::area; +template using mm2 = units::isq::si::area; +template using cm2 = units::isq::si::area; +template using dm2 = units::isq::si::area; +template using dam2 = units::isq::si::area; +template using hm2 = units::isq::si::area; +template using km2 = units::isq::si::area; +template using Mm2 = units::isq::si::area; +template using Gm2 = units::isq::si::area; +template using Tm2 = units::isq::si::area; +template using Pm2 = units::isq::si::area; +template using Em2 = units::isq::si::area; +template using Zm2 = units::isq::si::area; +template using Ym2 = units::isq::si::area; + +template using ha = units::isq::si::area; + +} // namespace units::aliases::isq::si::inline area + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/capacitance.h b/src/systems/si/include/units/isq/si/capacitance.h index 62774493..989f3c2d 100644 --- a/src/systems/si/include/units/isq/si/capacitance.h +++ b/src/systems/si/include/units/isq/si/capacitance.h @@ -192,3 +192,33 @@ using namespace capacitance_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline capacitance { + +template using F = units::isq::si::capacitance; +template using yF = units::isq::si::capacitance; +template using zF = units::isq::si::capacitance; +template using aF = units::isq::si::capacitance; +template using fF = units::isq::si::capacitance; +template using pF = units::isq::si::capacitance; +template using nF = units::isq::si::capacitance; +template using uF = units::isq::si::capacitance; +template using mF = units::isq::si::capacitance; +template using cF = units::isq::si::capacitance; +template using dF = units::isq::si::capacitance; +template using daF = units::isq::si::capacitance; +template using hF = units::isq::si::capacitance; +template using kF = units::isq::si::capacitance; +template using MF = units::isq::si::capacitance; +template using GF = units::isq::si::capacitance; +template using TF = units::isq::si::capacitance; +template using PF = units::isq::si::capacitance; +template using EF = units::isq::si::capacitance; +template using ZF = units::isq::si::capacitance; +template using YF = units::isq::si::capacitance; + +} // namespace units::aliases::isq::si::inline capacitance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/catalytic_activity.h b/src/systems/si/include/units/isq/si/catalytic_activity.h index f822da23..d544ca6a 100644 --- a/src/systems/si/include/units/isq/si/catalytic_activity.h +++ b/src/systems/si/include/units/isq/si/catalytic_activity.h @@ -188,7 +188,7 @@ inline constexpr auto Zkat = reference{}; inline constexpr auto Ykat = reference{}; inline constexpr auto U = reference{}; -} +} // namespace catalytic_activity_references namespace references { @@ -199,3 +199,34 @@ using namespace catalytic_activity_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline catalytic_activity { + +template using kat = units::isq::si::catalytic_activity; +template using ykat = units::isq::si::catalytic_activity; +template using zkat = units::isq::si::catalytic_activity; +template using akat = units::isq::si::catalytic_activity; +template using fkat = units::isq::si::catalytic_activity; +template using pkat = units::isq::si::catalytic_activity; +template using nkat = units::isq::si::catalytic_activity; +template using ukat = units::isq::si::catalytic_activity; +template using mkat = units::isq::si::catalytic_activity; +template using ckat = units::isq::si::catalytic_activity; +template using dkat = units::isq::si::catalytic_activity; +template using dakat = units::isq::si::catalytic_activity; +template using hkat = units::isq::si::catalytic_activity; +template using kkat = units::isq::si::catalytic_activity; +template using Mkat = units::isq::si::catalytic_activity; +template using Gkat = units::isq::si::catalytic_activity; +template using Tkat = units::isq::si::catalytic_activity; +template using Pkat = units::isq::si::catalytic_activity; +template using Ekat = units::isq::si::catalytic_activity; +template using Zkat = units::isq::si::catalytic_activity; +template using Ykat = units::isq::si::catalytic_activity; +template using U = units::isq::si::catalytic_activity; + +} // namespace units::aliases::isq::si::inline catalytic_activity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/charge_density.h b/src/systems/si/include/units/isq/si/charge_density.h index 05388d6e..441cb5fc 100644 --- a/src/systems/si/include/units/isq/si/charge_density.h +++ b/src/systems/si/include/units/isq/si/charge_density.h @@ -64,3 +64,14 @@ constexpr auto operator"" _q_C_per_m2(long double l) { return surface_charge_den #endif // UNITS_LITERALS } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline charge_density { + +template using C_per_m3 = units::isq::si::charge_density; +template using C_per_m2 = units::isq::si::surface_charge_density; + +} // namespace units::aliases::isq::si::inline charge_density + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/concentration.h b/src/systems/si/include/units/isq/si/concentration.h index 64351e4b..99a99ae8 100644 --- a/src/systems/si/include/units/isq/si/concentration.h +++ b/src/systems/si/include/units/isq/si/concentration.h @@ -54,3 +54,12 @@ constexpr auto operator"" _q_mol_per_m3(long double l) { return concentration using mol_per_m3 = units::isq::si::concentration; + +} // namespace units::aliases::isq::si::inline concentration + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/conductance.h b/src/systems/si/include/units/isq/si/conductance.h index 8a903af5..11877476 100644 --- a/src/systems/si/include/units/isq/si/conductance.h +++ b/src/systems/si/include/units/isq/si/conductance.h @@ -168,3 +168,28 @@ using namespace conductance_references; } // namespace units::isq::si +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline conductance { + +template using S = units::isq::si::conductance; +template using yS = units::isq::si::conductance; +template using zS = units::isq::si::conductance; +template using aS = units::isq::si::conductance; +template using fS = units::isq::si::conductance; +template using pS = units::isq::si::conductance; +template using nS = units::isq::si::conductance; +template using uS = units::isq::si::conductance; +template using mS = units::isq::si::conductance; +template using kS = units::isq::si::conductance; +template using MS = units::isq::si::conductance; +template using GS = units::isq::si::conductance; +template using TS = units::isq::si::conductance; +template using PS = units::isq::si::conductance; +template using ES = units::isq::si::conductance; +template using ZS = units::isq::si::conductance; +template using YS = units::isq::si::conductance; + +} // namespace units::aliases::isq::si::inline conductance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/current_density.h b/src/systems/si/include/units/isq/si/current_density.h index 38e53119..0a680666 100644 --- a/src/systems/si/include/units/isq/si/current_density.h +++ b/src/systems/si/include/units/isq/si/current_density.h @@ -55,3 +55,13 @@ constexpr auto operator"" _q_A_per_m2(long double l) { return current_density using A_per_m2 = units::isq::si::current_density; + +} // namespace units::aliases::isq::si::inline current_density + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/density.h b/src/systems/si/include/units/isq/si/density.h index bc0a65e8..192c16b6 100644 --- a/src/systems/si/include/units/isq/si/density.h +++ b/src/systems/si/include/units/isq/si/density.h @@ -55,3 +55,13 @@ constexpr auto operator"" _q_kg_per_m3(long double l) { return density using kg_per_m3 = units::isq::si::density; + +} // namespace units::aliases::isq::si::inline density + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/dynamic_viscosity.h b/src/systems/si/include/units/isq/si/dynamic_viscosity.h index c127218b..5ee4571f 100644 --- a/src/systems/si/include/units/isq/si/dynamic_viscosity.h +++ b/src/systems/si/include/units/isq/si/dynamic_viscosity.h @@ -54,3 +54,12 @@ constexpr auto operator"" _q_Pa_s(long double l) { return dynamic_viscosity using Pa_s = units::isq::si::dynamic_viscosity; + +} // namespace units::aliases::isq::si::inline dynamic_viscosity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_charge.h b/src/systems/si/include/units/isq/si/electric_charge.h index 497b12a1..7dd60373 100644 --- a/src/systems/si/include/units/isq/si/electric_charge.h +++ b/src/systems/si/include/units/isq/si/electric_charge.h @@ -71,3 +71,13 @@ using namespace electric_charge_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline electric_charge { + +template using C = units::isq::si::electric_charge; + +} // namespace units::aliases::isq::si::inline electric_charge + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_current.h b/src/systems/si/include/units/isq/si/electric_current.h index a8c3ff74..f295862a 100644 --- a/src/systems/si/include/units/isq/si/electric_current.h +++ b/src/systems/si/include/units/isq/si/electric_current.h @@ -190,3 +190,33 @@ using namespace electric_current_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline electric_current { + +template using A = units::isq::si::electric_current; +template using yA = units::isq::si::electric_current; +template using zA = units::isq::si::electric_current; +template using aA = units::isq::si::electric_current; +template using fA = units::isq::si::electric_current; +template using pA = units::isq::si::electric_current; +template using nA = units::isq::si::electric_current; +template using uA = units::isq::si::electric_current; +template using mA = units::isq::si::electric_current; +template using cA = units::isq::si::electric_current; +template using dA = units::isq::si::electric_current; +template using daA = units::isq::si::electric_current; +template using hA = units::isq::si::electric_current; +template using kA = units::isq::si::electric_current; +template using MA = units::isq::si::electric_current; +template using GA = units::isq::si::electric_current; +template using TA = units::isq::si::electric_current; +template using PA = units::isq::si::electric_current; +template using EA = units::isq::si::electric_current; +template using ZA = units::isq::si::electric_current; +template using YA = units::isq::si::electric_current; + +} // namespace units::aliases::isq::si::inline electric_current + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_field_strength.h b/src/systems/si/include/units/isq/si/electric_field_strength.h index e100855c..ec11149c 100644 --- a/src/systems/si/include/units/isq/si/electric_field_strength.h +++ b/src/systems/si/include/units/isq/si/electric_field_strength.h @@ -52,3 +52,13 @@ constexpr auto operator"" _q_V_per_m(long double l) { return electric_field_stre #endif // UNITS_LITERALS } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline electric_field_strength { + +template using V_per_m = units::isq::si::electric_field_strength; + +} // namespace units::aliases::isq::si::inline electric_field_strength + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/energy.h b/src/systems/si/include/units/isq/si/energy.h index 9170b42f..f4a36b16 100644 --- a/src/systems/si/include/units/isq/si/energy.h +++ b/src/systems/si/include/units/isq/si/energy.h @@ -181,3 +181,32 @@ using namespace energy_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline energy { + +template using J = units::isq::si::energy; +template using yJ = units::isq::si::energy; +template using zJ = units::isq::si::energy; +template using aJ = units::isq::si::energy; +template using fJ = units::isq::si::energy; +template using pJ = units::isq::si::energy; +template using nJ = units::isq::si::energy; +template using uJ = units::isq::si::energy; +template using mJ = units::isq::si::energy; +template using kJ = units::isq::si::energy; +template using MJ = units::isq::si::energy; +template using GJ = units::isq::si::energy; +template using TJ = units::isq::si::energy; +template using PJ = units::isq::si::energy; +template using EJ = units::isq::si::energy; +template using ZJ = units::isq::si::energy; +template using YJ = units::isq::si::energy; + +template using eV = units::isq::si::energy; +template using GeV = units::isq::si::energy; + +} // namespace units::aliases::isq::si::inline energy + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/energy_density.h b/src/systems/si/include/units/isq/si/energy_density.h index 60009957..3bafc229 100644 --- a/src/systems/si/include/units/isq/si/energy_density.h +++ b/src/systems/si/include/units/isq/si/energy_density.h @@ -53,3 +53,13 @@ constexpr auto operator"" _q_J_per_m3(long double l) { return energy_density using J_per_m3 = units::isq::si::energy_density; + +} // namespace units::aliases::isq::si::inline energy_density + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/force.h b/src/systems/si/include/units/isq/si/force.h index 095f2489..09bb70ae 100644 --- a/src/systems/si/include/units/isq/si/force.h +++ b/src/systems/si/include/units/isq/si/force.h @@ -192,3 +192,33 @@ using namespace force_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline force { + +template using N = units::isq::si::force; +template using yN = units::isq::si::force; +template using zN = units::isq::si::force; +template using aN = units::isq::si::force; +template using fN = units::isq::si::force; +template using pN = units::isq::si::force; +template using nN = units::isq::si::force; +template using uN = units::isq::si::force; +template using mN = units::isq::si::force; +template using cN = units::isq::si::force; +template using dN = units::isq::si::force; +template using daN = units::isq::si::force; +template using hN = units::isq::si::force; +template using kN = units::isq::si::force; +template using MN = units::isq::si::force; +template using GN = units::isq::si::force; +template using TN = units::isq::si::force; +template using PN = units::isq::si::force; +template using EN = units::isq::si::force; +template using ZN = units::isq::si::force; +template using YN = units::isq::si::force; + +} // namespace units::aliases::isq::si::inline force + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/frequency.h b/src/systems/si/include/units/isq/si/frequency.h index 90447db8..251d4692 100644 --- a/src/systems/si/include/units/isq/si/frequency.h +++ b/src/systems/si/include/units/isq/si/frequency.h @@ -166,3 +166,29 @@ using namespace frequency_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline frequency { + +template using Hz = units::isq::si::frequency; +template using yHz = units::isq::si::frequency; +template using zHz = units::isq::si::frequency; +template using aHz = units::isq::si::frequency; +template using fHz = units::isq::si::frequency; +template using pHz = units::isq::si::frequency; +template using nHz = units::isq::si::frequency; +template using uHz = units::isq::si::frequency; +template using mHz = units::isq::si::frequency; +template using kHz = units::isq::si::frequency; +template using MHz = units::isq::si::frequency; +template using GHz = units::isq::si::frequency; +template using THz = units::isq::si::frequency; +template using PHz = units::isq::si::frequency; +template using EHz = units::isq::si::frequency; +template using ZHz = units::isq::si::frequency; +template using YHz = units::isq::si::frequency; + +} // namespace units::aliases::isq::si::inline frequency + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/heat_capacity.h b/src/systems/si/include/units/isq/si/heat_capacity.h index 848a50b5..fe34c473 100644 --- a/src/systems/si/include/units/isq/si/heat_capacity.h +++ b/src/systems/si/include/units/isq/si/heat_capacity.h @@ -75,3 +75,14 @@ constexpr auto operator"" _q_J_per_mol_K(long double l) { return molar_heat_capa } // namespace units::isq::si +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::heat_capacity { + +template using J_per_K = units::isq::si::heat_capacity; +template using J_per_kg_K = units::isq::si::specific_heat_capacity; +template using J_per_mol_K = units::isq::si::molar_heat_capacity; + +} // namespace units::aliases::isq::si::heat_capacity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/inductance.h b/src/systems/si/include/units/isq/si/inductance.h index f373952d..82fcb963 100644 --- a/src/systems/si/include/units/isq/si/inductance.h +++ b/src/systems/si/include/units/isq/si/inductance.h @@ -168,3 +168,29 @@ using namespace inductance_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline inductance { + +template using H = units::isq::si::inductance; +template using yH = units::isq::si::inductance; +template using zH = units::isq::si::inductance; +template using aH = units::isq::si::inductance; +template using fH = units::isq::si::inductance; +template using pH = units::isq::si::inductance; +template using nH = units::isq::si::inductance; +template using uH = units::isq::si::inductance; +template using mH = units::isq::si::inductance; +template using kH = units::isq::si::inductance; +template using MH = units::isq::si::inductance; +template using GH = units::isq::si::inductance; +template using TH = units::isq::si::inductance; +template using PH = units::isq::si::inductance; +template using EH = units::isq::si::inductance; +template using ZH = units::isq::si::inductance; +template using YH = units::isq::si::inductance; + +} // namespace units::aliases::isq::si::inline inductance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/length.h b/src/systems/si/include/units/isq/si/length.h index d1069252..43891d81 100644 --- a/src/systems/si/include/units/isq/si/length.h +++ b/src/systems/si/include/units/isq/si/length.h @@ -197,3 +197,34 @@ using namespace length_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline length { + +template using m = units::isq::si::length; +template using ym = units::isq::si::length; +template using zm = units::isq::si::length; +template using am = units::isq::si::length; +template using fm = units::isq::si::length; +template using pm = units::isq::si::length; +template using nm = units::isq::si::length; +template using um = units::isq::si::length; +template using mm = units::isq::si::length; +template using cm = units::isq::si::length; +template using dm = units::isq::si::length; +template using dam = units::isq::si::length; +template using hm = units::isq::si::length; +template using km = units::isq::si::length; +template using Mm = units::isq::si::length; +template using Gm = units::isq::si::length; +template using Tm = units::isq::si::length; +template using Pm = units::isq::si::length; +template using Em = units::isq::si::length; +template using Zm = units::isq::si::length; +template using Ym = units::isq::si::length; +template using au = units::isq::si::length; + +} // namespace units::aliases::isq::si::inline length + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminance.h b/src/systems/si/include/units/isq/si/luminance.h index d41b2c06..87b81e3c 100644 --- a/src/systems/si/include/units/isq/si/luminance.h +++ b/src/systems/si/include/units/isq/si/luminance.h @@ -54,3 +54,12 @@ constexpr auto operator"" _q_cd_per_m2(long double l) { return luminance using cd_per_m2 = units::isq::si::luminance; + +} // namespace units::aliases::isq::si::inline luminance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/luminous_intensity.h b/src/systems/si/include/units/isq/si/luminous_intensity.h index 3bd8288f..85299c40 100644 --- a/src/systems/si/include/units/isq/si/luminous_intensity.h +++ b/src/systems/si/include/units/isq/si/luminous_intensity.h @@ -190,3 +190,33 @@ using namespace luminous_intensity_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::luminous_intensity { + +template using cd = units::isq::si::luminous_intensity; +template using ycd = units::isq::si::luminous_intensity; +template using zcd = units::isq::si::luminous_intensity; +template using acd = units::isq::si::luminous_intensity; +template using fcd = units::isq::si::luminous_intensity; +template using pcd = units::isq::si::luminous_intensity; +template using ncd = units::isq::si::luminous_intensity; +template using ucd = units::isq::si::luminous_intensity; +template using mcd = units::isq::si::luminous_intensity; +template using ccd = units::isq::si::luminous_intensity; +template using dcd = units::isq::si::luminous_intensity; +template using dacd = units::isq::si::luminous_intensity; +template using hcd = units::isq::si::luminous_intensity; +template using kcd = units::isq::si::luminous_intensity; +template using Mcd = units::isq::si::luminous_intensity; +template using Gcd = units::isq::si::luminous_intensity; +template using Tcd = units::isq::si::luminous_intensity; +template using Pcd = units::isq::si::luminous_intensity; +template using Ecd = units::isq::si::luminous_intensity; +template using Zcd = units::isq::si::luminous_intensity; +template using Ycd = units::isq::si::luminous_intensity; + +} // namespace units::aliases::isq::si::luminous_intensity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/magnetic_flux.h b/src/systems/si/include/units/isq/si/magnetic_flux.h index 44305370..e106f6fd 100644 --- a/src/systems/si/include/units/isq/si/magnetic_flux.h +++ b/src/systems/si/include/units/isq/si/magnetic_flux.h @@ -168,3 +168,29 @@ using namespace magnetic_flux_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline magnetic_flux { + +template using Wb = units::isq::si::magnetic_flux; +template using yWb = units::isq::si::magnetic_flux; +template using zWb = units::isq::si::magnetic_flux; +template using aWb = units::isq::si::magnetic_flux; +template using fWb = units::isq::si::magnetic_flux; +template using pWb = units::isq::si::magnetic_flux; +template using nWb = units::isq::si::magnetic_flux; +template using uWb = units::isq::si::magnetic_flux; +template using mWb = units::isq::si::magnetic_flux; +template using kWb = units::isq::si::magnetic_flux; +template using MWb = units::isq::si::magnetic_flux; +template using GWb = units::isq::si::magnetic_flux; +template using TWb = units::isq::si::magnetic_flux; +template using PWb = units::isq::si::magnetic_flux; +template using EWb = units::isq::si::magnetic_flux; +template using ZWb = units::isq::si::magnetic_flux; +template using YWb = units::isq::si::magnetic_flux; + +} // namespace units::aliases::isq::si::inline magnetic_flux + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/magnetic_induction.h b/src/systems/si/include/units/isq/si/magnetic_induction.h index 6b0320ae..cfccd5da 100644 --- a/src/systems/si/include/units/isq/si/magnetic_induction.h +++ b/src/systems/si/include/units/isq/si/magnetic_induction.h @@ -176,4 +176,31 @@ using namespace magnetic_induction_references; #endif // UNITS_REFERENCES -} // namespace units +} // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline magnetic_induction { + +template using T = units::isq::si::magnetic_induction; +template using yT = units::isq::si::magnetic_induction; +template using zT = units::isq::si::magnetic_induction; +template using aT = units::isq::si::magnetic_induction; +template using fT = units::isq::si::magnetic_induction; +template using pT = units::isq::si::magnetic_induction; +template using nT = units::isq::si::magnetic_induction; +template using uT = units::isq::si::magnetic_induction; +template using mT = units::isq::si::magnetic_induction; +template using kT = units::isq::si::magnetic_induction; +template using MT = units::isq::si::magnetic_induction; +template using GT = units::isq::si::magnetic_induction; +template using TT = units::isq::si::magnetic_induction; +template using PT = units::isq::si::magnetic_induction; +template using ET = units::isq::si::magnetic_induction; +template using ZT = units::isq::si::magnetic_induction; +template using YT = units::isq::si::magnetic_induction; +template using G = units::isq::si::magnetic_induction; + +} // namespace units::aliases::isq::si::inline magnetic_induction + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/mass.h b/src/systems/si/include/units/isq/si/mass.h index 32a7d94b..38fc58f8 100644 --- a/src/systems/si/include/units/isq/si/mass.h +++ b/src/systems/si/include/units/isq/si/mass.h @@ -291,6 +291,7 @@ inline constexpr auto Pg = reference{}; inline constexpr auto Eg = reference{}; inline constexpr auto Zg = reference{}; inline constexpr auto Yg = reference{}; + inline constexpr auto t = reference{}; inline constexpr auto yt = reference{}; inline constexpr auto zt = reference{}; @@ -325,3 +326,56 @@ using namespace mass_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline mass { + +template using g = units::isq::si::mass; +template using yg = units::isq::si::mass; +template using zg = units::isq::si::mass; +template using ag = units::isq::si::mass; +template using fg = units::isq::si::mass; +template using pg = units::isq::si::mass; +template using ng = units::isq::si::mass; +template using ug = units::isq::si::mass; +template using mg = units::isq::si::mass; +template using cg = units::isq::si::mass; +template using dg = units::isq::si::mass; +template using dag = units::isq::si::mass; +template using hg = units::isq::si::mass; +template using kg = units::isq::si::mass; +template using Mg = units::isq::si::mass; +template using Gg = units::isq::si::mass; +template using Tg = units::isq::si::mass; +template using Pg = units::isq::si::mass; +template using Eg = units::isq::si::mass; +template using Zg = units::isq::si::mass; +template using Yg = units::isq::si::mass; + +template using t = units::isq::si::mass; +template using yt = units::isq::si::mass; +template using zt = units::isq::si::mass; +template using at = units::isq::si::mass; +template using ft = units::isq::si::mass; +template using pt = units::isq::si::mass; +template using nt = units::isq::si::mass; +template using ut = units::isq::si::mass; +template using mt = units::isq::si::mass; +template using ct = units::isq::si::mass; +template using dt = units::isq::si::mass; +template using dat = units::isq::si::mass; +template using ht = units::isq::si::mass; +template using kt = units::isq::si::mass; +template using Mt = units::isq::si::mass; +template using Gt = units::isq::si::mass; +template using Tt = units::isq::si::mass; +template using Pt = units::isq::si::mass; +template using Et = units::isq::si::mass; +template using Zt = units::isq::si::mass; +template using Yt = units::isq::si::mass; +template using Da = units::isq::si::mass; + +} // namespace units::aliases::isq::si::inline mass + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/molar_energy.h b/src/systems/si/include/units/isq/si/molar_energy.h index d9443ad8..d3d3d734 100644 --- a/src/systems/si/include/units/isq/si/molar_energy.h +++ b/src/systems/si/include/units/isq/si/molar_energy.h @@ -55,3 +55,13 @@ constexpr auto operator"" _q_J_per_mol(long double l) { return molar_energy using J_per_mol = units::isq::si::molar_energy; + +} // namespace units::aliases::isq::si::inline molar_energy + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/momentum.h b/src/systems/si/include/units/isq/si/momentum.h index ec1faa94..0123837f 100644 --- a/src/systems/si/include/units/isq/si/momentum.h +++ b/src/systems/si/include/units/isq/si/momentum.h @@ -53,3 +53,13 @@ constexpr auto operator"" _q_kg_m_per_s(long double l) { return momentum using kg_m_per_s = units::isq::si::momentum; + +} // namespace units::aliases::isq::si::inline momentum + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/permeability.h b/src/systems/si/include/units/isq/si/permeability.h index e846e282..3b16a50b 100644 --- a/src/systems/si/include/units/isq/si/permeability.h +++ b/src/systems/si/include/units/isq/si/permeability.h @@ -55,3 +55,12 @@ constexpr auto operator"" _q_H_per_m(long double l) { return permeability using H_per_m = units::isq::si::permeability; + +} // namespace units::aliases::isq::si::inline permeability + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/permittivity.h b/src/systems/si/include/units/isq/si/permittivity.h index 46d6bbf8..d367b518 100644 --- a/src/systems/si/include/units/isq/si/permittivity.h +++ b/src/systems/si/include/units/isq/si/permittivity.h @@ -55,3 +55,12 @@ constexpr auto operator"" _q_F_per_m(long double l) { return permittivity using F_per_m = units::isq::si::permittivity; + +} // namespace units::aliases::isq::si::inline permittivity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/power.h b/src/systems/si/include/units/isq/si/power.h index d741def6..371385fb 100644 --- a/src/systems/si/include/units/isq/si/power.h +++ b/src/systems/si/include/units/isq/si/power.h @@ -167,3 +167,29 @@ using namespace power_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline power { + +template using W = units::isq::si::power; +template using yW = units::isq::si::power; +template using zW = units::isq::si::power; +template using aW = units::isq::si::power; +template using fW = units::isq::si::power; +template using pW = units::isq::si::power; +template using nW = units::isq::si::power; +template using uW = units::isq::si::power; +template using mW = units::isq::si::power; +template using kW = units::isq::si::power; +template using MW = units::isq::si::power; +template using GW = units::isq::si::power; +template using TW = units::isq::si::power; +template using PW = units::isq::si::power; +template using EW = units::isq::si::power; +template using ZW = units::isq::si::power; +template using YW = units::isq::si::power; + +} // namespace units::aliases::isq::si::inline power + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/pressure.h b/src/systems/si/include/units/isq/si/pressure.h index 5ffc6522..637a2558 100644 --- a/src/systems/si/include/units/isq/si/pressure.h +++ b/src/systems/si/include/units/isq/si/pressure.h @@ -192,3 +192,33 @@ using namespace pressure_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline pressure { + +template using Pa = units::isq::si::pressure; +template using yPa = units::isq::si::pressure; +template using zPa = units::isq::si::pressure; +template using aPa = units::isq::si::pressure; +template using fPa = units::isq::si::pressure; +template using pPa = units::isq::si::pressure; +template using nPa = units::isq::si::pressure; +template using uPa = units::isq::si::pressure; +template using mPa = units::isq::si::pressure; +template using cPa = units::isq::si::pressure; +template using dPa = units::isq::si::pressure; +template using daPa = units::isq::si::pressure; +template using hPa = units::isq::si::pressure; +template using kPa = units::isq::si::pressure; +template using MPa = units::isq::si::pressure; +template using GPa = units::isq::si::pressure; +template using TPa = units::isq::si::pressure; +template using PPa = units::isq::si::pressure; +template using EPa = units::isq::si::pressure; +template using ZPa = units::isq::si::pressure; +template using YPa = units::isq::si::pressure; + +} // namespace units::aliases::isq::si::inline pressure + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/radioactivity.h b/src/systems/si/include/units/isq/si/radioactivity.h index 7531edd1..c122e80f 100644 --- a/src/systems/si/include/units/isq/si/radioactivity.h +++ b/src/systems/si/include/units/isq/si/radioactivity.h @@ -190,3 +190,33 @@ using namespace radioactivity_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline radioactivity { + +template using Bq = units::isq::radioactivity; +template using yBq = units::isq::radioactivity; +template using zBq = units::isq::radioactivity; +template using aBq = units::isq::radioactivity; +template using fBq = units::isq::radioactivity; +template using pBq = units::isq::radioactivity; +template using nBq = units::isq::radioactivity; +template using uBq = units::isq::radioactivity; +template using mBq = units::isq::radioactivity; +template using cBq = units::isq::radioactivity; +template using dBq = units::isq::radioactivity; +template using daBq = units::isq::radioactivity; +template using hBq = units::isq::radioactivity; +template using kBq = units::isq::radioactivity; +template using MBq = units::isq::radioactivity; +template using GBq = units::isq::radioactivity; +template using TBq = units::isq::radioactivity; +template using PBq = units::isq::radioactivity; +template using EBq = units::isq::radioactivity; +template using ZBq = units::isq::radioactivity; +template using YBq = units::isq::radioactivity; + +} // namespace units::aliases::isq::si::inline radioactivity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/resistance.h b/src/systems/si/include/units/isq/si/resistance.h index cf689bb2..37f7fbbc 100644 --- a/src/systems/si/include/units/isq/si/resistance.h +++ b/src/systems/si/include/units/isq/si/resistance.h @@ -168,3 +168,29 @@ using namespace resistance_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline resistance { + +template using R = units::isq::si::resistance; +template using yR = units::isq::si::resistance; +template using zR = units::isq::si::resistance; +template using aR = units::isq::si::resistance; +template using fR = units::isq::si::resistance; +template using pR = units::isq::si::resistance; +template using nR = units::isq::si::resistance; +template using uR = units::isq::si::resistance; +template using mR = units::isq::si::resistance; +template using kR = units::isq::si::resistance; +template using MR = units::isq::si::resistance; +template using GR = units::isq::si::resistance; +template using TR = units::isq::si::resistance; +template using PR = units::isq::si::resistance; +template using ER = units::isq::si::resistance; +template using ZR = units::isq::si::resistance; +template using YR = units::isq::si::resistance; + +} // namespace units::aliases::isq::si::inline resistance + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/speed.h b/src/systems/si/include/units/isq/si/speed.h index 38b9fff0..d9a73cc6 100644 --- a/src/systems/si/include/units/isq/si/speed.h +++ b/src/systems/si/include/units/isq/si/speed.h @@ -59,3 +59,14 @@ constexpr auto operator"" _q_km_per_h(long double l) { return speed using m_per_s = units::isq::si::speed; +template using km_per_h = units::isq::si::speed; + +} // namespace units::aliases::isq::si::inline speed + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/surface_tension.h b/src/systems/si/include/units/isq/si/surface_tension.h index a5f01cf5..70f7088c 100644 --- a/src/systems/si/include/units/isq/si/surface_tension.h +++ b/src/systems/si/include/units/isq/si/surface_tension.h @@ -53,3 +53,13 @@ constexpr auto operator"" _q_N_per_m(long double l) { return surface_tension using N_per_m = units::isq::si::surface_tension; + +} // namespace units::aliases::isq::si::inline surface_tension + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/thermal_conductivity.h b/src/systems/si/include/units/isq/si/thermal_conductivity.h index 45f72a38..b85eff41 100644 --- a/src/systems/si/include/units/isq/si/thermal_conductivity.h +++ b/src/systems/si/include/units/isq/si/thermal_conductivity.h @@ -54,3 +54,13 @@ constexpr auto operator"" _q_W_per_m_K(long double l) { return thermal_conductiv #endif // UNITS_LITERALS } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline thermal_conductivity { + +template using W_per_m_K = units::isq::si::thermal_conductivity; + +} // namespace units::aliases::isq::si::inline thermal_conductivity + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h index f2bbf7cf..e1cbf0f8 100644 --- a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h +++ b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h @@ -69,3 +69,13 @@ using namespace thermodynamic_temperature_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline thermodynamic_temperature { + +template using K = units::isq::si::thermodynamic_temperature; + +} // namespace units::aliases::isq::si::inline thermodynamic_temperature + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/time.h b/src/systems/si/include/units/isq/si/time.h index 82f9febe..d9201b67 100644 --- a/src/systems/si/include/units/isq/si/time.h +++ b/src/systems/si/include/units/isq/si/time.h @@ -136,3 +136,24 @@ using namespace time_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline time { + +template using ys = units::isq::si::time; +template using zs = units::isq::si::time; +template using as = units::isq::si::time; +template using fs = units::isq::si::time; +template using ps = units::isq::si::time; +template using ns = units::isq::si::time; +template using us = units::isq::si::time; +template using ms = units::isq::si::time; +template using s = units::isq::si::time; +template using min = units::isq::si::time; +template using h = units::isq::si::time; +template using d = units::isq::si::time; + +} // namespace units::aliases::isq::si::inline time + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/torque.h b/src/systems/si/include/units/isq/si/torque.h index e6631130..6639b476 100644 --- a/src/systems/si/include/units/isq/si/torque.h +++ b/src/systems/si/include/units/isq/si/torque.h @@ -55,3 +55,13 @@ constexpr auto operator"" _q_N_m_per_rad(long double l) { return torque using N_m_per_rad = units::isq::si::torque; + +} // namespace units::aliases::isq::si::inline torque + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/voltage.h b/src/systems/si/include/units/isq/si/voltage.h index a124f1fe..ce50f61e 100644 --- a/src/systems/si/include/units/isq/si/voltage.h +++ b/src/systems/si/include/units/isq/si/voltage.h @@ -192,3 +192,33 @@ using namespace voltage_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline voltage { + +template using V = units::isq::si::voltage; +template using yV = units::isq::si::voltage; +template using zV = units::isq::si::voltage; +template using aV = units::isq::si::voltage; +template using fV = units::isq::si::voltage; +template using pV = units::isq::si::voltage; +template using nV = units::isq::si::voltage; +template using uV = units::isq::si::voltage; +template using mV = units::isq::si::voltage; +template using cV = units::isq::si::voltage; +template using dV = units::isq::si::voltage; +template using daV = units::isq::si::voltage; +template using hV = units::isq::si::voltage; +template using kV = units::isq::si::voltage; +template using MV = units::isq::si::voltage; +template using GV = units::isq::si::voltage; +template using TV = units::isq::si::voltage; +template using PV = units::isq::si::voltage; +template using EV = units::isq::si::voltage; +template using ZV = units::isq::si::voltage; +template using YV = units::isq::si::voltage; + +} // namespace units::aliases::isq::si::inline voltage + +#endif // UNITS_ALIASES diff --git a/src/systems/si/include/units/isq/si/volume.h b/src/systems/si/include/units/isq/si/volume.h index dc6bdfe8..03c4de7a 100644 --- a/src/systems/si/include/units/isq/si/volume.h +++ b/src/systems/si/include/units/isq/si/volume.h @@ -284,6 +284,7 @@ inline constexpr auto Pm3 = reference{}; inline constexpr auto Em3 = reference{}; inline constexpr auto Zm3 = reference{}; inline constexpr auto Ym3 = reference{}; + inline constexpr auto l = reference{}; inline constexpr auto yl = reference{}; inline constexpr auto zl = reference{}; @@ -317,3 +318,55 @@ using namespace volume_references; #endif // UNITS_REFERENCES } // namespace units::isq::si + +#ifdef UNITS_ALIASES + +namespace units::aliases::isq::si::inline volume { + +template using m3 = units::isq::si::volume; +template using ym3 = units::isq::si::volume; +template using zm3 = units::isq::si::volume; +template using am3 = units::isq::si::volume; +template using fm3 = units::isq::si::volume; +template using pm3 = units::isq::si::volume; +template using nm3 = units::isq::si::volume; +template using um3 = units::isq::si::volume; +template using mm3 = units::isq::si::volume; +template using cm3 = units::isq::si::volume; +template using dm3 = units::isq::si::volume; +template using dam3 = units::isq::si::volume; +template using hm3 = units::isq::si::volume; +template using km3 = units::isq::si::volume; +template using Mm3 = units::isq::si::volume; +template using Gm3 = units::isq::si::volume; +template using Tm3 = units::isq::si::volume; +template using Pm3 = units::isq::si::volume; +template using Em3 = units::isq::si::volume; +template using Zm3 = units::isq::si::volume; +template using Ym3 = units::isq::si::volume; + +template using l = units::isq::si::volume; +template using yl = units::isq::si::volume; +template using zl = units::isq::si::volume; +template using al = units::isq::si::volume; +template using fl = units::isq::si::volume; +template using pl = units::isq::si::volume; +template using nl = units::isq::si::volume; +template using ul = units::isq::si::volume; +template using ml = units::isq::si::volume; +template using cl = units::isq::si::volume; +template using dl = units::isq::si::volume; +template using dal = units::isq::si::volume; +template using hl = units::isq::si::volume; +template using kl = units::isq::si::volume; +template using Ml = units::isq::si::volume; +template using Gl = units::isq::si::volume; +template using Tl = units::isq::si::volume; +template using Pl = units::isq::si::volume; +template using El = units::isq::si::volume; +template using Zl = units::isq::si::volume; +template using Yl = units::isq::si::volume; + +} // namespace units::aliases::isq::si::inline volume + +#endif // UNITS_ALIASES diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index b8537ccd..3cb48f4f 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -38,6 +38,7 @@ target_link_libraries(unit_tests_runtime PRIVATE target_compile_definitions(unit_tests_runtime PRIVATE UNITS_REFERENCES UNITS_LITERALS + UNITS_ALIASES ) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index 399e6fa6..5a234641 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -40,6 +40,7 @@ target_compile_options(unit_tests_static_truncating PRIVATE target_compile_definitions(unit_tests_static_truncating PRIVATE UNITS_REFERENCES UNITS_LITERALS + UNITS_ALIASES ) add_library(unit_tests_static @@ -80,4 +81,5 @@ target_link_libraries(unit_tests_static PRIVATE target_compile_definitions(unit_tests_static PRIVATE UNITS_REFERENCES UNITS_LITERALS + UNITS_ALIASES )