From 18620044c55ab45de465e6bb063a8d4cf066a4a1 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 17 Feb 2020 15:56:06 +0100 Subject: [PATCH] All UDLs are now prefixed with `q_` --- README.md | 28 +-- doc/DESIGN.md | 48 ++-- example/avg_velocity.cpp | 18 +- example/box_example.cpp | 8 +- example/capacitor_time_curve.cpp | 16 +- example/clcpp_response.cpp | 26 +-- example/conversion_factor.cpp | 2 +- example/hello_units.cpp | 2 +- example/unknown_dimension.cpp | 10 +- src/include/units/data/bitrate.h | 12 +- src/include/units/data/information.h | 24 +- src/include/units/physical/cgs/acceleration.h | 4 +- src/include/units/physical/cgs/area.h | 4 +- src/include/units/physical/cgs/energy.h | 4 +- src/include/units/physical/cgs/force.h | 4 +- src/include/units/physical/cgs/length.h | 4 +- src/include/units/physical/cgs/mass.h | 4 +- src/include/units/physical/cgs/power.h | 4 +- src/include/units/physical/cgs/pressure.h | 4 +- src/include/units/physical/cgs/time.h | 2 +- src/include/units/physical/cgs/velocity.h | 4 +- src/include/units/physical/iau/length.h | 12 +- src/include/units/physical/imperial/length.h | 8 +- .../units/physical/international/area.h | 4 +- .../units/physical/international/length.h | 32 +-- .../units/physical/international/velocity.h | 4 +- .../units/physical/international/volume.h | 4 +- src/include/units/physical/si/acceleration.h | 4 +- src/include/units/physical/si/area.h | 24 +- src/include/units/physical/si/capacitance.h | 20 +- src/include/units/physical/si/current.h | 4 +- src/include/units/physical/si/density.h | 4 +- .../units/physical/si/electric_charge.h | 4 +- src/include/units/physical/si/energy.h | 28 +-- src/include/units/physical/si/force.h | 4 +- src/include/units/physical/si/frequency.h | 24 +- src/include/units/physical/si/length.h | 32 +-- .../units/physical/si/luminous_intensity.h | 4 +- src/include/units/physical/si/mass.h | 16 +- src/include/units/physical/si/power.h | 20 +- src/include/units/physical/si/pressure.h | 4 +- src/include/units/physical/si/resistance.h | 16 +- src/include/units/physical/si/substance.h | 4 +- .../units/physical/si/surface_tension.h | 4 +- src/include/units/physical/si/temperature.h | 4 +- src/include/units/physical/si/time.h | 28 +-- src/include/units/physical/si/velocity.h | 8 +- src/include/units/physical/si/voltage.h | 20 +- src/include/units/physical/si/volume.h | 20 +- .../units/physical/typographic/length.h | 16 +- src/include/units/physical/us/length.h | 12 +- src/include/units/quantity_cast.h | 8 +- test/unit_test/runtime/digital_info_test.cpp | 8 +- test/unit_test/runtime/fmt_test.cpp | 218 +++++++++--------- test/unit_test/runtime/fmt_units_test.cpp | 132 +++++------ test/unit_test/runtime/math_test.cpp | 10 +- test/unit_test/static/cgs_test.cpp | 40 ++-- test/unit_test/static/custom_unit_test.cpp | 2 +- test/unit_test/static/data_test.cpp | 20 +- test/unit_test/static/math_test.cpp | 16 +- test/unit_test/static/quantity_test.cpp | 154 ++++++------- test/unit_test/static/si_cgs_test.cpp | 98 ++++---- test/unit_test/static/si_test.cpp | 196 ++++++++-------- test/unit_test/static/us_test.cpp | 12 +- test_package/test_package.cpp | 2 +- 65 files changed, 768 insertions(+), 768 deletions(-) diff --git a/README.md b/README.md index 72ea6219..213b396a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ constexpr Velocity auto avg_speed(Length auto d, Time auto t) int main() { using namespace si::literals; - Velocity auto v1 = avg_speed(220km, 2h); + Velocity auto v1 = avg_speed(220q_km, 2q_h); Velocity auto v2 = avg_speed(si::length(140), si::time(2)); Velocity auto v3 = quantity_cast(v2); Velocity auto v4 = quantity_cast(v3); @@ -50,20 +50,20 @@ Here is a small example of possible operations: ```cpp // simple numeric operations -static_assert(10km / 2 == 5km); +static_assert(10q_km / 2 == 5q_km); // unit conversions -static_assert(1h == 3600s); -static_assert(1km + 1m == 1001m); +static_assert(1q_h == 3600q_s); +static_assert(1q_km + 1q_m == 1001q_m); // dimension conversions -static_assert(1km / 1s == 1000mps); -static_assert(2kmph * 2h == 4km); -static_assert(2km / 2kmph == 1h); +static_assert(1q_km / 1q_s == 1000q_mps); +static_assert(2q_kmph * 2q_h == 4q_km); +static_assert(2q_km / 2q_kmph == 1q_h); -static_assert(1000 / 1s == 1kHz); +static_assert(1000 / 1q_s == 1q_kHz); -static_assert(10km / 5km == 2); +static_assert(10q_km / 5q_km == 2); ``` @@ -90,7 +90,7 @@ Thanks to them the same code can be as simple as: ```cpp using namespace units::si::literals; -auto d = 123km; // units::length +auto d = 123q_km; // units::length ``` For brevity, the next examples will assume: @@ -105,8 +105,8 @@ Let's assume that the user wants to write the following code: int main() { using namespace si::literals; - auto v1 = avg_speed(220km, 2h); - auto v2 = avg_speed(140mi, 2h); + auto v1 = avg_speed(220q_km, 2q_h); + auto v2 = avg_speed(140q_mi, 2q_h); // ... } ``` @@ -156,8 +156,8 @@ int main() { using namespace si::literals; using namespace international::literals; - Velocity auto v1 = avg_speed(220km, 2h); - Velocity auto v2 = avg_speed(140mi, 2h); + Velocity auto v1 = avg_speed(220q_km, 2q_h); + Velocity auto v2 = avg_speed(140q_mi, 2q_h); std::cout << v1 << '\n'; // 110 km/h std::cout << quantity_cast(speed) << '\n'; // 30.5556 m/s diff --git a/doc/DESIGN.md b/doc/DESIGN.md index 9c08d448..255db6a3 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -11,20 +11,20 @@ Here is a small example of possible operations: ```cpp // simple numeric operations -static_assert(10km / 2 == 5km); +static_assert(10q_km / 2 == 5q_km); // unit conversions -static_assert(1h == 3600s); -static_assert(1km + 1m == 1001m); +static_assert(1q_h == 3600q_s); +static_assert(1q_km + 1q_m == 1001q_m); // dimension conversions -static_assert(1km / 1s == 1000mps); -static_assert(2kmph * 2h == 4km); -static_assert(2km / 2kmph == 1h); +static_assert(1q_km / 1q_s == 1000q_mps); +static_assert(2q_kmph * 2q_h == 4q_km); +static_assert(2q_km / 2q_kmph == 1q_h); -static_assert(1000 / 1s == 1kHz); +static_assert(1000 / 1q_s == 1q_kHz); -static_assert(10km / 5km == 2); +static_assert(10q_km / 5q_km == 2); ``` @@ -458,12 +458,12 @@ has an associated UDL. For example: namespace si::inline literals { // m -constexpr auto operator"" m(unsigned long long l) { return length(l); } -constexpr auto operator"" m(long double l) { return length(l); } +constexpr auto operator"" q_m(unsigned long long l) { return length(l); } +constexpr auto operator"" q_m(long double l) { return length(l); } // km -constexpr auto operator"" km(unsigned long long l) { return length(l); } -constexpr auto operator"" km(long double l) { return length(l); } +constexpr auto operator"" q_km(unsigned long long l) { return length(l); } +constexpr auto operator"" q_km(long double l) { return length(l); } } ``` @@ -574,7 +574,7 @@ If the `units-specs` is omitted, the `quantity` object is formatted as if by str additional padding and adjustments as specified by the format specifiers. ```cpp -std::string s = fmt::format("{:=>12}", 120_kmph); // value of s is "====120 km/h" +std::string s = fmt::format("{:=>12}", 120q_kmph); // value of s is "====120 km/h" ``` @@ -732,14 +732,14 @@ predefined by the user in the downcasting facility. A typical example of such a temporary results of calculations: ```cpp -units::Length auto d1 = 123m; -units::Time auto t1 = 10s; +units::Length auto d1 = 123q_m; +units::Time auto t1 = 10q_s; units::Velocity auto v1 = avg_speed(d1, t1); -auto temp1 = v1 * 50m; // intermediate unknown dimension +auto temp1 = v1 * 50q_m; // intermediate unknown dimension -units::Velocity auto v2 = temp1 / 100m; // back to known dimensions again -units::Length auto d2 = v2 * 60s; +units::Velocity auto v2 = temp1 / 100q_m; // back to known dimensions again +units::Length auto d2 = v2 * 60q_s; ``` To provide support to form an unknown derived dimension that could be than be converted to a @@ -825,12 +825,12 @@ adds support for digital information quantities. In summary it adds: namespace units::data::inline literals { // bits - constexpr auto operator""b(unsigned long long l) { return information(l); } - constexpr auto operator""Kib(unsigned long long l) { return information(l); } + constexpr auto operator"" q_b(unsigned long long l) { return information(l); } + constexpr auto operator"" q_Kib(unsigned long long l) { return information(l); } // bytes - constexpr auto operator""B(unsigned long long l) { return information(l); } - constexpr auto operator""KiB(unsigned long long l) { return information(l); } + constexpr auto operator"" q_B(unsigned long long l) { return information(l); } + constexpr auto operator"" q_KiB(unsigned long long l) { return information(l); } } ``` @@ -854,8 +854,8 @@ adds support for digital information quantities. In summary it adds: inline namespace literals { // bits - constexpr auto operator""_bps(unsigned long long l) { return bitrate(l); } - constexpr auto operator""_Kibps(unsigned long long l) { return bitrate(l); } + constexpr auto operator"" q_bps(unsigned long long l) { return bitrate(l); } + constexpr auto operator"" q_Kibps(unsigned long long l) { return bitrate(l); } } diff --git a/example/avg_velocity.cpp b/example/avg_velocity.cpp index 74a09259..e66c1c5f 100644 --- a/example/avg_velocity.cpp +++ b/example/avg_velocity.cpp @@ -68,7 +68,7 @@ void example() // SI (int) { using namespace units::si::literals; - constexpr Length AUTO distance = 220km; // constructed from a UDL + constexpr Length AUTO distance = 220q_km; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "SI units with 'int' as representation\n"; @@ -82,8 +82,8 @@ void example() // SI (double) { using namespace units::si::literals; - constexpr Length AUTO distance = 220.km; // constructed from a UDL - constexpr si::time duration(2); // constructed from a value + constexpr Length AUTO distance = 220.q_km; // constructed from a UDL + constexpr si::time duration(2); // constructed from a value std::cout << "\nSI units with 'double' as representation\n"; @@ -98,7 +98,7 @@ void example() // Customary Units (int) { using namespace units::international::literals; - constexpr Length AUTO distance = 140mi; // constructed from a UDL + constexpr Length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "\nUS Customary Units with 'int' as representation\n"; @@ -114,7 +114,7 @@ void example() // Customary Units (double) { using namespace units::international::literals; - constexpr Length AUTO distance = 140.mi; // constructed from a UDL + constexpr Length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "\nUS Customary Units with 'double' as representation\n"; @@ -132,8 +132,8 @@ void example() // CGS (int) { using namespace units::cgs::literals; - constexpr Length AUTO distance = 22'000'000cm; // constructed from a UDL - constexpr cgs::time duration(2); // constructed from a value + constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL + constexpr cgs::time duration(2); // constructed from a value std::cout << "\nCGS units with 'int' as representation\n"; @@ -151,8 +151,8 @@ void example() // CGS (double) { using namespace units::cgs::literals; - constexpr Length AUTO distance = 22'000'000.cm; // constructed from a UDL - constexpr cgs::time duration(2); // constructed from a value + constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL + constexpr cgs::time duration(2); // constructed from a value std::cout << "\nCGS units with 'double' as representation\n"; diff --git a/example/box_example.cpp b/example/box_example.cpp index ad9caa4f..795697da 100644 --- a/example/box_example.cpp +++ b/example/box_example.cpp @@ -101,11 +101,11 @@ struct Box { using namespace units::si::literals; int main() { - auto box = Box{1000.0mm, 500.0mm, 200.0mm}; - box.set_contents_density(1000.0kgpm3); + auto box = Box{1000.0q_mm, 500.0q_mm, 200.0q_mm}; + box.set_contents_density(1000.0q_kgpm3); - auto fill_time = 200.0s; // time since starting fill - auto measured_mass = 20.0kg; // measured mass at fill_time + auto fill_time = 200.0q_s; // time since starting fill + auto measured_mass = 20.0q_kg; // measured mass at fill_time std::cout << "mpusz/units box example...\n"; std::cout << "fill height at " << fill_time << " = " << box.fill_level(measured_mass) << " (" diff --git a/example/capacitor_time_curve.cpp b/example/capacitor_time_curve.cpp index 07cdc1cf..9ef501d7 100644 --- a/example/capacitor_time_curve.cpp +++ b/example/capacitor_time_curve.cpp @@ -56,22 +56,22 @@ int main() std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); std::cout.precision(3); - constexpr auto C = 0.47uF; - constexpr auto V0 = 5.0V; - constexpr auto R = 4.7kR; + constexpr auto C = 0.47q_uF; + constexpr auto V0 = 5.0q_V; + constexpr auto R = 4.7q_kR; - for (auto t = 0ms; t <= 50ms; ++t) { + for (auto t = 0q_ms; t <= 50q_ms; ++t) { const auto Vt = V0 * std::exp(-t / (R * C)); std::cout << "at " << t << " voltage is "; - if (Vt >= 1V) + if (Vt >= 1q_V) std::cout << Vt; - else if (Vt >= 1mV) + else if (Vt >= 1q_mV) std::cout << voltage::mV<>{Vt}; - else if (Vt >= 1uV) + else if (Vt >= 1q_uV) std::cout << voltage::uV<>{Vt}; - else if (Vt >= 1nV) + else if (Vt >= 1q_nV) std::cout << voltage::nV<>{Vt}; else std::cout << voltage::pV<>{Vt}; diff --git a/example/clcpp_response.cpp b/example/clcpp_response.cpp index 1d113f1c..94a26faa 100644 --- a/example/clcpp_response.cpp +++ b/example/clcpp_response.cpp @@ -130,12 +130,12 @@ void simple_quantities() using distance = length::m<>; using time = time::s<>; - constexpr distance km = 1.0km; - constexpr distance miles = 1.0mi; + constexpr distance km = 1.0q_km; + constexpr distance miles = 1.0q_mi; - constexpr time sec = 1s; - constexpr time min = 1min; - constexpr time hr = 1h; + constexpr time sec = 1q_s; + constexpr time min = 1q_min; + constexpr time hr = 1q_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"; @@ -148,14 +148,14 @@ void simple_quantities() void quantities_with_typed_units() { - constexpr length::km<> km = 1.0km; - constexpr length::mi<> miles = 1.0mi; + constexpr length::km<> km = 1.0q_km; + constexpr length::mi<> miles = 1.0q_mi; std::cout.precision(6); - constexpr time::s<> sec = 1s; - constexpr time::min<> min = 1min; - constexpr time::h<> hr = 1h; + constexpr time::s<> sec = 1q_s; + constexpr time::min<> min = 1q_min; + constexpr time::h<> hr = 1q_h; std::cout << "A more flexible option is to provide separate types for each unit,\n\n"; std::cout << km << '\n'; @@ -164,7 +164,7 @@ void quantities_with_typed_units() std::cout << min << '\n'; std::cout << hr << "\n\n"; - constexpr length::m<> meter = 1m; + constexpr length::m<> meter = 1q_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"; @@ -197,8 +197,8 @@ void calcs_comparison() "when adding two values of the same very big\n" "or very small type:\n\n"; - length::fm L1A = 2fm; - length::fm L2A = 3fm; + length::fm L1A = 2q_fm; + length::fm L2A = 3q_fm; length::fm LrA = L1A + L2A; std::cout << L1A << " + " << L2A << " = " << LrA << "\n\n"; diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 0c0eaf70..259dfa38 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -64,7 +64,7 @@ int main() { std::cout << "conversion factor in mpusz/units...\n\n"; - constexpr length::m<> lengthA = 2.0m; + constexpr length::m<> lengthA = 2.0q_m; constexpr length::mm<> lengthB = lengthA; std::cout << "lengthA( " << lengthA << " ) and lengthB( " << lengthB << " )\n" diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 5aa8b5e4..dc21299a 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -35,7 +35,7 @@ constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) int main() { using namespace si::literals; - Velocity AUTO v1 = avg_speed(220km, 2h); + Velocity AUTO v1 = avg_speed(220q_km, 2q_h); Velocity AUTO v2 = avg_speed(si::length(140), si::time(2)); Velocity AUTO v3 = quantity_cast(v2); Velocity AUTO v4 = quantity_cast(v3); diff --git a/example/unknown_dimension.cpp b/example/unknown_dimension.cpp index 9cd31340..ea51227b 100644 --- a/example/unknown_dimension.cpp +++ b/example/unknown_dimension.cpp @@ -35,13 +35,13 @@ void example() { using namespace units::si::literals; - units::Length AUTO d1 = 123m; - units::Time AUTO t1 = 10s; + units::Length AUTO d1 = 123q_m; + units::Time AUTO t1 = 10q_s; units::Velocity AUTO v1 = avg_speed(d1, t1); - auto temp1 = v1 * 50m; // produces intermediate unknown dimension with 'unknown_unit' as its 'coherent_unit' - units::Velocity AUTO v2 = temp1 / 100m; // back to known dimensions again - units::Length AUTO d2 = v2 * 60s; + auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_unit' as its 'coherent_unit' + units::Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again + units::Length AUTO d2 = v2 * 60q_s; std::cout << "d1 = " << d1 << '\n'; std::cout << "t1 = " << t1 << '\n'; diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index a14c3fb7..987d5b51 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -47,12 +47,12 @@ using bitrate = quantity; inline namespace literals { // bits -constexpr auto operator""bps(unsigned long long l) { return bitrate(l); } -constexpr auto operator""Kibps(unsigned long long l) { return bitrate(l); } -constexpr auto operator""Mibps(unsigned long long l) { return bitrate(l); } -constexpr auto operator""Gibps(unsigned long long l) { return bitrate(l); } -constexpr auto operator""Tibps(unsigned long long l) { return bitrate(l); } -constexpr auto operator""sPibps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_bps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_Kibps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_Mibps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_Gibps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_Tibps(unsigned long long l) { return bitrate(l); } +constexpr auto operator"" q_sPibps(unsigned long long l) { return bitrate(l); } } // namespace literals diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index 4d28f47b..8ecd3531 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -54,20 +54,20 @@ using information = quantity; inline namespace literals { // bits -constexpr auto operator""b(unsigned long long l) { return information(l); } -constexpr auto operator""Kib(unsigned long long l) { return information(l); } -constexpr auto operator""Mib(unsigned long long l) { return information(l); } -constexpr auto operator""Gib(unsigned long long l) { return information(l); } -constexpr auto operator""Tib(unsigned long long l) { return information(l); } -constexpr auto operator""Pib(unsigned long long l) { return information(l); } +constexpr auto operator"" q_b(unsigned long long l) { return information(l); } +constexpr auto operator"" q_Kib(unsigned long long l) { return information(l); } +constexpr auto operator"" q_Mib(unsigned long long l) { return information(l); } +constexpr auto operator"" q_Gib(unsigned long long l) { return information(l); } +constexpr auto operator"" q_Tib(unsigned long long l) { return information(l); } +constexpr auto operator"" q_Pib(unsigned long long l) { return information(l); } // bytes -constexpr auto operator""B(unsigned long long l) { return information(l); } -constexpr auto operator""KiB(unsigned long long l) { return information(l); } -constexpr auto operator""MiB(unsigned long long l) { return information(l); } -constexpr auto operator""GiB(unsigned long long l) { return information(l); } -constexpr auto operator""TiB(unsigned long long l) { return information(l); } -constexpr auto operator""PiB(unsigned long long l) { return information(l); } +constexpr auto operator"" q_B(unsigned long long l) { return information(l); } +constexpr auto operator"" q_KiB(unsigned long long l) { return information(l); } +constexpr auto operator"" q_MiB(unsigned long long l) { return information(l); } +constexpr auto operator"" q_GiB(unsigned long long l) { return information(l); } +constexpr auto operator"" q_TiB(unsigned long long l) { return information(l); } +constexpr auto operator"" q_PiB(unsigned long long l) { return information(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index 0c2b488a..38375002 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -37,8 +37,8 @@ using acceleration = quantity; inline namespace literals { // Gal -constexpr auto operator""Gal(unsigned long long l) { return acceleration(l); } -constexpr auto operator""Gal(long double l) { return acceleration(l); } +constexpr auto operator"" q_Gal(unsigned long long l) { return acceleration(l); } +constexpr auto operator"" q_Gal(long double l) { return acceleration(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/area.h b/src/include/units/physical/cgs/area.h index 6facde0b..e9e0f74d 100644 --- a/src/include/units/physical/cgs/area.h +++ b/src/include/units/physical/cgs/area.h @@ -39,8 +39,8 @@ using area = quantity; inline namespace literals { // cm2 -constexpr auto operator"" cm2(unsigned long long l) { return area(l); } -constexpr auto operator"" cm2(long double l) { return area(l); } +constexpr auto operator"" q_cm2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_cm2(long double l) { return area(l); } } diff --git a/src/include/units/physical/cgs/energy.h b/src/include/units/physical/cgs/energy.h index 413eb773..61dd495e 100644 --- a/src/include/units/physical/cgs/energy.h +++ b/src/include/units/physical/cgs/energy.h @@ -39,8 +39,8 @@ using energy = quantity; inline namespace literals { // erg -constexpr auto operator""_erg(unsigned long long l) { return energy(l); } -constexpr auto operator""_erg(long double l) { return energy(l); } +constexpr auto operator"" q_erg(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_erg(long double l) { return energy(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index d9f9a1a7..19644b16 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -40,8 +40,8 @@ using force = quantity; inline namespace literals { // dyn -constexpr auto operator""dyn(unsigned long long l) { return force(l); } -constexpr auto operator""dyn(long double l) { return force(l); } +constexpr auto operator"" q_dyn(unsigned long long l) { return force(l); } +constexpr auto operator"" q_dyn(long double l) { return force(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index a49a4cb8..2584cfe4 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -38,8 +38,8 @@ using length = quantity; inline namespace literals { // cm -constexpr auto operator"" cm(unsigned long long l) { return length(l); } -constexpr auto operator"" cm(long double l) { return length(l); } +constexpr auto operator"" q_cm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_cm(long double l) { return length(l); } } diff --git a/src/include/units/physical/cgs/mass.h b/src/include/units/physical/cgs/mass.h index d809eb32..e372e198 100644 --- a/src/include/units/physical/cgs/mass.h +++ b/src/include/units/physical/cgs/mass.h @@ -38,8 +38,8 @@ using mass = quantity; inline namespace literals { // g -constexpr auto operator""g(unsigned long long l) { return mass(l); } -constexpr auto operator""g(long double l) { return mass(l); } +constexpr auto operator"" q_g(unsigned long long l) { return mass(l); } +constexpr auto operator"" q_g(long double l) { return mass(l); } } diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index 5a813cb2..148b0c9b 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -39,8 +39,8 @@ using power = quantity; inline namespace literals { // ergps -constexpr auto operator""_ergps(unsigned long long l) { return power(l); } -constexpr auto operator""_ergps(long double l) { return power(l); } +constexpr auto operator"" q_ergps(unsigned long long l) { return power(l); } +constexpr auto operator"" q_ergps(long double l) { return power(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/pressure.h b/src/include/units/physical/cgs/pressure.h index 0e3b98d4..33a0a2bd 100644 --- a/src/include/units/physical/cgs/pressure.h +++ b/src/include/units/physical/cgs/pressure.h @@ -40,8 +40,8 @@ using pressure = quantity; inline namespace literals { // Ba -constexpr auto operator""Ba(unsigned long long l) { return pressure(l); } -constexpr auto operator""Ba(long double l) { return pressure(l); } +constexpr auto operator"" q_Ba(unsigned long long l) { return pressure(l); } +constexpr auto operator"" q_Ba(long double l) { return pressure(l); } } // namespace literals diff --git a/src/include/units/physical/cgs/time.h b/src/include/units/physical/cgs/time.h index c678bc79..c3ed5f77 100644 --- a/src/include/units/physical/cgs/time.h +++ b/src/include/units/physical/cgs/time.h @@ -35,7 +35,7 @@ using si::time; inline namespace literals { -using si::literals::operator"" s; +using si::literals::operator"" q_s; } diff --git a/src/include/units/physical/cgs/velocity.h b/src/include/units/physical/cgs/velocity.h index 8adbaa58..61fa20ca 100644 --- a/src/include/units/physical/cgs/velocity.h +++ b/src/include/units/physical/cgs/velocity.h @@ -38,8 +38,8 @@ using velocity = quantity; inline namespace literals { // cmps -constexpr auto operator"" cmps(unsigned long long l) { return velocity(l); } -constexpr auto operator"" cmps(long double l) { return velocity(l); } +constexpr auto operator"" q_cmps(unsigned long long l) { return velocity(l); } +constexpr auto operator"" q_cmps(long double l) { return velocity(l); } } // namespace literals diff --git a/src/include/units/physical/iau/length.h b/src/include/units/physical/iau/length.h index f7acbd76..f3ca07fd 100644 --- a/src/include/units/physical/iau/length.h +++ b/src/include/units/physical/iau/length.h @@ -38,14 +38,14 @@ struct angstrom : named_scaled_unit(l); } -constexpr auto operator"" ly(long double l) { return si::length(l); } +constexpr auto operator"" q_ly(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_ly(long double l) { return si::length(l); } -constexpr auto operator"" pc(unsigned long long l) { return si::length(l); } -constexpr auto operator"" pc(long double l) { return si::length(l); } +constexpr auto operator"" q_pc(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_pc(long double l) { return si::length(l); } -constexpr auto operator"" angstrom(unsigned long long l) { return si::length(l); } -constexpr auto operator"" angstrom(long double l) { return si::length(l); } +constexpr auto operator"" q_angstrom(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_angstrom(long double l) { return si::length(l); } } // namespace literals diff --git a/src/include/units/physical/imperial/length.h b/src/include/units/physical/imperial/length.h index 3e049898..3db68318 100644 --- a/src/include/units/physical/imperial/length.h +++ b/src/include/units/physical/imperial/length.h @@ -34,11 +34,11 @@ struct rod : named_scaled_unit, chain> {}; inline namespace literals { -constexpr auto operator"" ch(unsigned long long l) { return si::length(l); } -constexpr auto operator"" ch(long double l) { return si::length(l); } +constexpr auto operator"" q_ch(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_ch(long double l) { return si::length(l); } -constexpr auto operator"" rd(unsigned long long l) { return si::length(l); } -constexpr auto operator"" rd(long double l) { return si::length(l); } +constexpr auto operator"" q_rd(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_rd(long double l) { return si::length(l); } } // namespace literals diff --git a/src/include/units/physical/international/area.h b/src/include/units/physical/international/area.h index 9ed8f0d1..dcc09320 100644 --- a/src/include/units/physical/international/area.h +++ b/src/include/units/physical/international/area.h @@ -32,8 +32,8 @@ struct square_foot : deduced_unit(l); } -constexpr auto operator"" ft2(long double l) { return si::area(l); } +constexpr auto operator"" q_ft2(unsigned long long l) { return si::area(l); } +constexpr auto operator"" q_ft2(long double l) { return si::area(l); } } // namespace literals diff --git a/src/include/units/physical/international/length.h b/src/include/units/physical/international/length.h index adf6b984..3cd32e5e 100644 --- a/src/include/units/physical/international/length.h +++ b/src/include/units/physical/international/length.h @@ -61,36 +61,36 @@ using mil = thou; inline namespace literals { // yd -constexpr auto operator"" yd(unsigned long long l) { return si::length(l); } -constexpr auto operator"" yd(long double l) { return si::length(l); } +constexpr auto operator"" q_yd(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_yd(long double l) { return si::length(l); } // ft -constexpr auto operator"" ft(unsigned long long l) { return si::length(l); } -constexpr auto operator"" ft(long double l) { return si::length(l); } +constexpr auto operator"" q_ft(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_ft(long double l) { return si::length(l); } // fathom -constexpr auto operator"" fathom(unsigned long long l) { return si::length(l); } -constexpr auto operator"" fathom(long double l) { return si::length(l); } +constexpr auto operator"" q_fathom(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_fathom(long double l) { return si::length(l); } // in -constexpr auto operator"" in(unsigned long long l) { return si::length(l); } -constexpr auto operator"" in(long double l) { return si::length(l); } +constexpr auto operator"" q_in(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_in(long double l) { return si::length(l); } // mi -constexpr auto operator"" mi(unsigned long long l) { return si::length(l); } -constexpr auto operator"" mi(long double l) { return si::length(l); } +constexpr auto operator"" q_mi(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_mi(long double l) { return si::length(l); } // mi_naut -constexpr auto operator"" naut_mi(unsigned long long l) { return si::length(l); } -constexpr auto operator"" naut_mi(long double l) { return si::length(l); } +constexpr auto operator"" q_naut_mi(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_naut_mi(long double l) { return si::length(l); } // thou -constexpr auto operator"" thou(unsigned long long l) { return si::length(l); } -constexpr auto operator"" thou(long double l) { return si::length(l); } +constexpr auto operator"" q_thou(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_thou(long double l) { return si::length(l); } // mil -constexpr auto operator"" mil(unsigned long long l) { return si::length(l); } -constexpr auto operator"" mil(long double l) { return si::length(l); } +constexpr auto operator"" q_mil(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_mil(long double l) { return si::length(l); } } // namespace literals diff --git a/src/include/units/physical/international/velocity.h b/src/include/units/physical/international/velocity.h index ca678fd7..723356c9 100644 --- a/src/include/units/physical/international/velocity.h +++ b/src/include/units/physical/international/velocity.h @@ -32,8 +32,8 @@ struct mile_per_hour : deduced_unit(l); } -constexpr auto operator"" mph(long double l) { return si::velocity(l); } +constexpr auto operator"" q_mph(unsigned long long l) { return si::velocity(l); } +constexpr auto operator"" q_mph(long double l) { return si::velocity(l); } } // namespace literals diff --git a/src/include/units/physical/international/volume.h b/src/include/units/physical/international/volume.h index a5de2e39..9d596600 100644 --- a/src/include/units/physical/international/volume.h +++ b/src/include/units/physical/international/volume.h @@ -32,8 +32,8 @@ struct cubic_foot : deduced_unit(l); } -constexpr auto operator""ft3(long double l) { return si::volume(l); } +constexpr auto operator"" q_ft3(unsigned long long l) { return si::volume(l); } +constexpr auto operator"" q_ft3(long double l) { return si::volume(l); } } // namespace literals diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index 9bb311a3..6c336522 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -37,8 +37,8 @@ using acceleration = quantity; inline namespace literals { // mps2 -constexpr auto operator""mps2(unsigned long long l) { return acceleration(l); } -constexpr auto operator""mps2(long double l) { return acceleration(l); } +constexpr auto operator"" q_mps2(unsigned long long l) { return acceleration(l); } +constexpr auto operator"" q_mps2(long double l) { return acceleration(l); } } // namespace literals diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index c06077dd..3f01ce08 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -44,28 +44,28 @@ using area = quantity; inline namespace literals { // m2 -constexpr auto operator"" m2(unsigned long long l) { return area(l); } -constexpr auto operator"" m2(long double l) { return area(l); } +constexpr auto operator"" q_m2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_m2(long double l) { return area(l); } // mm2 -constexpr auto operator"" mm2(unsigned long long l) { return area(l); } -constexpr auto operator"" mm2(long double l) { return area(l); } +constexpr auto operator"" q_mm2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_mm2(long double l) { return area(l); } // cm2 -constexpr auto operator"" cm2(unsigned long long l) { return area(l); } -constexpr auto operator"" cm2(long double l) { return area(l); } +constexpr auto operator"" q_cm2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_cm2(long double l) { return area(l); } // fm2 -constexpr auto operator"" fm2(unsigned long long l) { return area(l); } -constexpr auto operator"" fm2(long double l) { return area(l); } +constexpr auto operator"" q_fm2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_fm2(long double l) { return area(l); } // km2 -constexpr auto operator"" km2(unsigned long long l) { return area(l); } -constexpr auto operator"" km2(long double l) { return area(l); } +constexpr auto operator"" q_km2(unsigned long long l) { return area(l); } +constexpr auto operator"" q_km2(long double l) { return area(l); } // ha -constexpr auto operator"" ha(unsigned long long l) { return area(l); } -constexpr auto operator"" ha(long double l) { return area(l); } +constexpr auto operator"" q_ha(unsigned long long l) { return area(l); } +constexpr auto operator"" q_ha(long double l) { return area(l); } } // namespace literals diff --git a/src/include/units/physical/si/capacitance.h b/src/include/units/physical/si/capacitance.h index 170e091b..528e9056 100644 --- a/src/include/units/physical/si/capacitance.h +++ b/src/include/units/physical/si/capacitance.h @@ -45,20 +45,20 @@ using capacitance = quantity; inline namespace literals { // F -constexpr auto operator""F(unsigned long long l) { return capacitance(l); } -constexpr auto operator""_F(long double l) { return capacitance(l); } +constexpr auto operator"" q_F(unsigned long long l) { return capacitance(l); } +constexpr auto operator"" q_F(long double l) { return capacitance(l); } -constexpr auto operator""mF(unsigned long long l) { return capacitance(l); } -constexpr auto operator""mF(long double l) { return capacitance(l); } +constexpr auto operator"" q_mF(unsigned long long l) { return capacitance(l); } +constexpr auto operator"" q_mF(long double l) { return capacitance(l); } -constexpr auto operator""uF(unsigned long long l) { return capacitance(l); } -constexpr auto operator""uF(long double l) { return capacitance(l); } +constexpr auto operator"" q_uF(unsigned long long l) { return capacitance(l); } +constexpr auto operator"" q_uF(long double l) { return capacitance(l); } -constexpr auto operator""nF(unsigned long long l) { return capacitance(l); } -constexpr auto operator""nF(long double l) { return capacitance(l); } +constexpr auto operator"" q_nF(unsigned long long l) { return capacitance(l); } +constexpr auto operator"" q_nF(long double l) { return capacitance(l); } -constexpr auto operator""pF(unsigned long long l) { return capacitance(l); } -constexpr auto operator""pF(long double l) { return capacitance(l); } +constexpr auto operator"" q_pF(unsigned long long l) { return capacitance(l); } +constexpr auto operator"" q_pF(long double l) { return capacitance(l); } } // namespace literals diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index 26b5143b..0b062f4e 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -38,8 +38,8 @@ using current = quantity; inline namespace literals { // A -constexpr auto operator""A(unsigned long long l) { return current(l); } -constexpr auto operator""A(long double l) { return current(l); } +constexpr auto operator"" q_A(unsigned long long l) { return current(l); } +constexpr auto operator"" q_A(long double l) { return current(l); } } // namespace literals diff --git a/src/include/units/physical/si/density.h b/src/include/units/physical/si/density.h index 1686f2c5..fef95294 100644 --- a/src/include/units/physical/si/density.h +++ b/src/include/units/physical/si/density.h @@ -39,8 +39,8 @@ using density = quantity; inline namespace literals { -constexpr auto operator"" kgpm3(unsigned long long l) { return density(l); } -constexpr auto operator"" kgpm3(long double l) { return density(l); } +constexpr auto operator"" q_kgpm3(unsigned long long l) { return density(l); } +constexpr auto operator"" q_kgpm3(long double l) { return density(l); } } // namespace literals diff --git a/src/include/units/physical/si/electric_charge.h b/src/include/units/physical/si/electric_charge.h index c2059c98..f3460d18 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -39,8 +39,8 @@ using electric_charge = quantity; inline namespace literals { // C -constexpr auto operator""C(unsigned long long l) { return electric_charge(l); } -constexpr auto operator""C(long double l) { return electric_charge(l); } +constexpr auto operator"" q_C(unsigned long long l) { return electric_charge(l); } +constexpr auto operator"" q_C(long double l) { return electric_charge(l); } } // namespace literals diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index d7a1a842..e319d439 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -46,32 +46,32 @@ using energy = quantity; inline namespace literals { // J -constexpr auto operator""_J(unsigned long long l) { return energy(l); } -constexpr auto operator""_J(long double l) { return energy(l); } +constexpr auto operator"" q_J(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_J(long double l) { return energy(l); } // mJ -constexpr auto operator""mJ(unsigned long long l) { return energy(l); } -constexpr auto operator""mJ(long double l) { return energy(l); } +constexpr auto operator"" q_mJ(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_mJ(long double l) { return energy(l); } // kJ -constexpr auto operator""kJ(unsigned long long l) { return energy(l); } -constexpr auto operator""kJ(long double l) { return energy(l); } +constexpr auto operator"" q_kJ(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_kJ(long double l) { return energy(l); } // MJ -constexpr auto operator""MJ(unsigned long long l) { return energy(l); } -constexpr auto operator""MJ(long double l) { return energy(l); } +constexpr auto operator"" q_MJ(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_MJ(long double l) { return energy(l); } // GJ -constexpr auto operator""GJ(unsigned long long l) { return energy(l); } -constexpr auto operator""GJ(long double l) { return energy(l); } +constexpr auto operator"" q_GJ(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_GJ(long double l) { return energy(l); } // eV -constexpr auto operator""eV(unsigned long long l) { return energy(l); } -constexpr auto operator""eV(long double l) { return energy(l); } +constexpr auto operator"" q_eV(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_eV(long double l) { return energy(l); } // GeV -constexpr auto operator""GeV(unsigned long long l) { return energy(l); } -constexpr auto operator""GeV(long double l) { return energy(l); } +constexpr auto operator"" q_GeV(unsigned long long l) { return energy(l); } +constexpr auto operator"" q_GeV(long double l) { return energy(l); } } // namespace literals diff --git a/src/include/units/physical/si/force.h b/src/include/units/physical/si/force.h index e3f7cf19..472e3a73 100644 --- a/src/include/units/physical/si/force.h +++ b/src/include/units/physical/si/force.h @@ -40,8 +40,8 @@ using force = quantity; inline namespace literals { // N -constexpr auto operator""N(unsigned long long l) { return force(l); } -constexpr auto operator""N(long double l) { return force(l); } +constexpr auto operator"" q_N(unsigned long long l) { return force(l); } +constexpr auto operator"" q_N(long double l) { return force(l); } } // namespace literals diff --git a/src/include/units/physical/si/frequency.h b/src/include/units/physical/si/frequency.h index be896849..9c1ef10e 100644 --- a/src/include/units/physical/si/frequency.h +++ b/src/include/units/physical/si/frequency.h @@ -43,28 +43,28 @@ using frequency = quantity; inline namespace literals { // Hz -constexpr auto operator"" Hz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" Hz(long double l) { return frequency(l); } +constexpr auto operator"" q_Hz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_Hz(long double l) { return frequency(l); } // mHz -constexpr auto operator"" mHz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" mHz(long double l) { return frequency(l); } +constexpr auto operator"" q_mHz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_mHz(long double l) { return frequency(l); } // kHz -constexpr auto operator"" kHz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" kHz(long double l) { return frequency(l); } +constexpr auto operator"" q_kHz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_kHz(long double l) { return frequency(l); } // MHz -constexpr auto operator"" MHz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" MHz(long double l) { return frequency(l); } +constexpr auto operator"" q_MHz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_MHz(long double l) { return frequency(l); } // GHz -constexpr auto operator"" GHz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" GHz(long double l) { return frequency(l); } +constexpr auto operator"" q_GHz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_GHz(long double l) { return frequency(l); } // THz -constexpr auto operator"" THz(unsigned long long l) { return frequency(l); } -constexpr auto operator"" THz(long double l) { return frequency(l); } +constexpr auto operator"" q_THz(unsigned long long l) { return frequency(l); } +constexpr auto operator"" q_THz(long double l) { return frequency(l); } } // namespace literals diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index 49b3c7e3..53543706 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -46,36 +46,36 @@ using length = quantity; inline namespace literals { // m -constexpr auto operator"" m(unsigned long long l) { return length(l); } -constexpr auto operator"" m(long double l) { return length(l); } +constexpr auto operator"" q_m(unsigned long long l) { return length(l); } +constexpr auto operator"" q_m(long double l) { return length(l); } // fm -constexpr auto operator"" fm(unsigned long long l) { return length(l); } -constexpr auto operator"" fm(long double l) { return length(l); } +constexpr auto operator"" q_fm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_fm(long double l) { return length(l); } // mm -constexpr auto operator"" mm(unsigned long long l) { return length(l); } -constexpr auto operator"" mm(long double l) { return length(l); } +constexpr auto operator"" q_mm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_mm(long double l) { return length(l); } // cm -constexpr auto operator"" cm(unsigned long long l) { return length(l); } -constexpr auto operator"" cm(long double l) { return length(l); } +constexpr auto operator"" q_cm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_cm(long double l) { return length(l); } // dm -constexpr auto operator"" dm(unsigned long long l) { return length(l); } -constexpr auto operator"" dm(long double l) { return length(l); } +constexpr auto operator"" q_dm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_dm(long double l) { return length(l); } // hm -constexpr auto operator"" hm(unsigned long long l) { return length(l); } -constexpr auto operator"" hm(long double l) { return length(l); } +constexpr auto operator"" q_hm(unsigned long long l) { return length(l); } +constexpr auto operator"" q_hm(long double l) { return length(l); } // km -constexpr auto operator"" km(unsigned long long l) { return length(l); } -constexpr auto operator"" km(long double l) { return length(l); } +constexpr auto operator"" q_km(unsigned long long l) { return length(l); } +constexpr auto operator"" q_km(long double l) { return length(l); } // au -constexpr auto operator"" au(unsigned long long l) { return length(l); } -constexpr auto operator"" au(long double l) { return length(l); } +constexpr auto operator"" q_au(unsigned long long l) { return length(l); } +constexpr auto operator"" q_au(long double l) { return length(l); } } // namespace literals diff --git a/src/include/units/physical/si/luminous_intensity.h b/src/include/units/physical/si/luminous_intensity.h index d3bcd5e2..9fde5ce7 100644 --- a/src/include/units/physical/si/luminous_intensity.h +++ b/src/include/units/physical/si/luminous_intensity.h @@ -38,8 +38,8 @@ using luminous_intensity = quantity; inline namespace literals { // cd -constexpr auto operator""cd(unsigned long long l) { return luminous_intensity(l); } -constexpr auto operator""cd(long double l) { return luminous_intensity(l); } +constexpr auto operator"" q_cd(unsigned long long l) { return luminous_intensity(l); } +constexpr auto operator"" q_cd(long double l) { return luminous_intensity(l); } } // namespace literals diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index 1a4dd5f0..ad9bb089 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -42,20 +42,20 @@ using mass = quantity; inline namespace literals { // g -constexpr auto operator""g(unsigned long long l) { return mass(l); } -constexpr auto operator""g(long double l) { return mass(l); } +constexpr auto operator"" q_g(unsigned long long l) { return mass(l); } +constexpr auto operator"" q_g(long double l) { return mass(l); } // kg -constexpr auto operator""kg(unsigned long long l) { return mass(l); } -constexpr auto operator""kg(long double l) { return mass(l); } +constexpr auto operator"" q_kg(unsigned long long l) { return mass(l); } +constexpr auto operator"" q_kg(long double l) { return mass(l); } // t -constexpr auto operator""t(unsigned long long l) { return mass(l); } -constexpr auto operator""t(long double l) { return mass(l); } +constexpr auto operator"" q_t(unsigned long long l) { return mass(l); } +constexpr auto operator"" q_t(long double l) { return mass(l); } // Da -constexpr auto operator""Da(unsigned long long l) { return mass(l); } -constexpr auto operator""Da(long double l) { return mass(l); } +constexpr auto operator"" q_Da(unsigned long long l) { return mass(l); } +constexpr auto operator"" q_Da(long double l) { return mass(l); } } // namespace literals diff --git a/src/include/units/physical/si/power.h b/src/include/units/physical/si/power.h index 072ede21..77e00287 100644 --- a/src/include/units/physical/si/power.h +++ b/src/include/units/physical/si/power.h @@ -43,24 +43,24 @@ using power = quantity; inline namespace literals { // W -constexpr auto operator""W(unsigned long long l) { return power(l); } -constexpr auto operator""_W(long double l) { return power(l); } +constexpr auto operator"" q_W(unsigned long long l) { return power(l); } +constexpr auto operator"" q_W(long double l) { return power(l); } // mW -constexpr auto operator""mW(unsigned long long l) { return power(l); } -constexpr auto operator""mW(long double l) { return power(l); } +constexpr auto operator"" q_mW(unsigned long long l) { return power(l); } +constexpr auto operator"" q_mW(long double l) { return power(l); } // kW -constexpr auto operator""kW(unsigned long long l) { return power(l); } -constexpr auto operator""kW(long double l) { return power(l); } +constexpr auto operator"" q_kW(unsigned long long l) { return power(l); } +constexpr auto operator"" q_kW(long double l) { return power(l); } // MW -constexpr auto operator""MW(unsigned long long l) { return power(l); } -constexpr auto operator""MW(long double l) { return power(l); } +constexpr auto operator"" q_MW(unsigned long long l) { return power(l); } +constexpr auto operator"" q_MW(long double l) { return power(l); } // GW -constexpr auto operator""GW(unsigned long long l) { return power(l); } -constexpr auto operator""GW(long double l) { return power(l); } +constexpr auto operator"" q_GW(unsigned long long l) { return power(l); } +constexpr auto operator"" q_GW(long double l) { return power(l); } } // namespace literals diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index a4256305..6ec97776 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -40,8 +40,8 @@ using pressure = quantity; inline namespace literals { // Pa -constexpr auto operator""Pa(unsigned long long l) { return pressure(l); } -constexpr auto operator""Pa(long double l) { return pressure(l); } +constexpr auto operator"" q_Pa(unsigned long long l) { return pressure(l); } +constexpr auto operator"" q_Pa(long double l) { return pressure(l); } } // namespace literals diff --git a/src/include/units/physical/si/resistance.h b/src/include/units/physical/si/resistance.h index 0ddddb60..28cb7930 100644 --- a/src/include/units/physical/si/resistance.h +++ b/src/include/units/physical/si/resistance.h @@ -43,20 +43,20 @@ using resistance = quantity; inline namespace literals { // R -constexpr auto operator""_R(unsigned long long l) { return resistance(l); } -constexpr auto operator""_R(long double l) { return resistance(l); } +constexpr auto operator"" q_R(unsigned long long l) { return resistance(l); } +constexpr auto operator"" q_R(long double l) { return resistance(l); } // mR -constexpr auto operator""mR(unsigned long long l) { return resistance(l); } -constexpr auto operator""mR(long double l) { return resistance(l); } +constexpr auto operator"" q_mR(unsigned long long l) { return resistance(l); } +constexpr auto operator"" q_mR(long double l) { return resistance(l); } // kR -constexpr auto operator""kR(unsigned long long l) { return resistance(l); } -constexpr auto operator""kR(long double l) { return resistance(l); } +constexpr auto operator"" q_kR(unsigned long long l) { return resistance(l); } +constexpr auto operator"" q_kR(long double l) { return resistance(l); } // MR -constexpr auto operator""MR(unsigned long long l) { return resistance(l); } -constexpr auto operator""MR(long double l) { return resistance(l); } +constexpr auto operator"" q_MR(unsigned long long l) { return resistance(l); } +constexpr auto operator"" q_MR(long double l) { return resistance(l); } } // namespace literals diff --git a/src/include/units/physical/si/substance.h b/src/include/units/physical/si/substance.h index 285fc33f..2fc76f5f 100644 --- a/src/include/units/physical/si/substance.h +++ b/src/include/units/physical/si/substance.h @@ -38,8 +38,8 @@ using substance = quantity; inline namespace literals { // mol -constexpr auto operator"" mol(unsigned long long l) { return substance(l); } -constexpr auto operator"" mol(long double l) { return substance(l); } +constexpr auto operator"" q_mol(unsigned long long l) { return substance(l); } +constexpr auto operator"" q_mol(long double l) { return substance(l); } } // namespace literals diff --git a/src/include/units/physical/si/surface_tension.h b/src/include/units/physical/si/surface_tension.h index 3e4b01b2..2fd4ba89 100644 --- a/src/include/units/physical/si/surface_tension.h +++ b/src/include/units/physical/si/surface_tension.h @@ -38,8 +38,8 @@ using surface_tension = quantity; inline namespace literals { // Nm - constexpr auto operator""Npm(unsigned long long l) { return surface_tension(l); } - constexpr auto operator""Npm(long double l) { return surface_tension(l); } + constexpr auto operator"" q_Npm(unsigned long long l) { return surface_tension(l); } + constexpr auto operator"" q_Npm(long double l) { return surface_tension(l); } } // namespace literals diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index a00ef3b1..ca409638 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -37,8 +37,8 @@ using temperature = quantity; inline namespace literals { // K -constexpr auto operator""K(unsigned long long l) { return temperature(l); } -constexpr auto operator""_K(long double l) { return temperature(l); } // TODO: conflicts with gcc GNU extension +constexpr auto operator"" q_K(unsigned long long l) { return temperature(l); } +constexpr auto operator"" q_K(long double l) { return temperature(l); } // TODO: conflicts with gcc GNU extension } // namespace literals diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index fcca48db..b60b799b 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -44,32 +44,32 @@ using time = quantity; inline namespace literals { // ns -constexpr auto operator""ns(unsigned long long l) { return time(l); } -constexpr auto operator""ns(long double l) { return time(l); } +constexpr auto operator"" q_ns(unsigned long long l) { return time(l); } +constexpr auto operator"" q_ns(long double l) { return time(l); } // us -constexpr auto operator""us(unsigned long long l) { return time(l); } -constexpr auto operator""us(long double l) { return time(l); } +constexpr auto operator"" q_us(unsigned long long l) { return time(l); } +constexpr auto operator"" q_us(long double l) { return time(l); } // ms -constexpr auto operator""ms(unsigned long long l) { return time(l); } -constexpr auto operator""ms(long double l) { return time(l); } +constexpr auto operator"" q_ms(unsigned long long l) { return time(l); } +constexpr auto operator"" q_ms(long double l) { return time(l); } // s -constexpr auto operator""s(unsigned long long l) { return time(l); } -constexpr auto operator""s(long double l) { return time(l); } +constexpr auto operator"" q_s(unsigned long long l) { return time(l); } +constexpr auto operator"" q_s(long double l) { return time(l); } // min -constexpr auto operator""min(unsigned long long l) { return time(l); } -constexpr auto operator""min(long double l) { return time(l); } +constexpr auto operator"" q_min(unsigned long long l) { return time(l); } +constexpr auto operator"" q_min(long double l) { return time(l); } // h -constexpr auto operator""h(unsigned long long l) { return time(l); } -constexpr auto operator""h(long double l) { return time(l); } +constexpr auto operator"" q_h(unsigned long long l) { return time(l); } +constexpr auto operator"" q_h(long double l) { return time(l); } // d -constexpr auto operator""_d(unsigned long long l) { return time(l); } -constexpr auto operator""_d(long double l) { return time(l); } +constexpr auto operator"" q_d(unsigned long long l) { return time(l); } +constexpr auto operator"" q_d(long double l) { return time(l); } } // namespace literals diff --git a/src/include/units/physical/si/velocity.h b/src/include/units/physical/si/velocity.h index f064d61c..825b6041 100644 --- a/src/include/units/physical/si/velocity.h +++ b/src/include/units/physical/si/velocity.h @@ -40,12 +40,12 @@ using velocity = quantity; inline namespace literals { // mps -constexpr auto operator"" mps(unsigned long long l) { return velocity(l); } -constexpr auto operator"" mps(long double l) { return velocity(l); } +constexpr auto operator"" q_mps(unsigned long long l) { return velocity(l); } +constexpr auto operator"" q_mps(long double l) { return velocity(l); } // kmph -constexpr auto operator"" kmph(unsigned long long l) { return velocity(l); } -constexpr auto operator"" kmph(long double l) { return velocity(l); } +constexpr auto operator"" q_kmph(unsigned long long l) { return velocity(l); } +constexpr auto operator"" q_kmph(long double l) { return velocity(l); } } // namespace literals diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index e1d97827..2b8bc18e 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -44,20 +44,20 @@ using voltage = quantity; inline namespace literals { // V -constexpr auto operator""V(unsigned long long l) { return voltage(l); } -constexpr auto operator""V(long double l) { return voltage(l); } +constexpr auto operator"" q_V(unsigned long long l) { return voltage(l); } +constexpr auto operator"" q_V(long double l) { return voltage(l); } -constexpr auto operator""mV(unsigned long long l) { return voltage(l); } -constexpr auto operator""mV(long double l) { return voltage(l); } +constexpr auto operator"" q_mV(unsigned long long l) { return voltage(l); } +constexpr auto operator"" q_mV(long double l) { return voltage(l); } -constexpr auto operator""uV(unsigned long long l) { return voltage(l); } -constexpr auto operator""uV(long double l) { return voltage(l); } +constexpr auto operator"" q_uV(unsigned long long l) { return voltage(l); } +constexpr auto operator"" q_uV(long double l) { return voltage(l); } -constexpr auto operator""nV(unsigned long long l) { return voltage(l); } -constexpr auto operator""nV(long double l) { return voltage(l); } +constexpr auto operator"" q_nV(unsigned long long l) { return voltage(l); } +constexpr auto operator"" q_nV(long double l) { return voltage(l); } -constexpr auto operator""pV(unsigned long long l) { return voltage(l); } -constexpr auto operator""pV(long double l) { return voltage(l); } +constexpr auto operator"" q_pV(unsigned long long l) { return voltage(l); } +constexpr auto operator"" q_pV(long double l) { return voltage(l); } } // namespace literals diff --git a/src/include/units/physical/si/volume.h b/src/include/units/physical/si/volume.h index 7d71e0a9..bf28d56d 100644 --- a/src/include/units/physical/si/volume.h +++ b/src/include/units/physical/si/volume.h @@ -44,24 +44,24 @@ using volume = quantity; inline namespace literals { // mm3 -constexpr auto operator""mm3(unsigned long long l) { return volume(l); } -constexpr auto operator""mm3(long double l) { return volume(l); } +constexpr auto operator"" q_mm3(unsigned long long l) { return volume(l); } +constexpr auto operator"" q_mm3(long double l) { return volume(l); } // cm3 -constexpr auto operator""cm3(unsigned long long l) { return volume(l); } -constexpr auto operator""cm3(long double l) { return volume(l); } +constexpr auto operator"" q_cm3(unsigned long long l) { return volume(l); } +constexpr auto operator"" q_cm3(long double l) { return volume(l); } // m3 -constexpr auto operator""m3(unsigned long long l) { return volume(l); } -constexpr auto operator""m3(long double l) { return volume(l); } +constexpr auto operator"" q_m3(unsigned long long l) { return volume(l); } +constexpr auto operator"" q_m3(long double l) { return volume(l); } // km3 -constexpr auto operator""km3(unsigned long long l) { return volume(l); } -constexpr auto operator""km3(long double l) { return volume(l); } +constexpr auto operator"" q_km3(unsigned long long l) { return volume(l); } +constexpr auto operator"" q_km3(long double l) { return volume(l); } // l -constexpr auto operator""_l(unsigned long long l) { return volume(l); } -constexpr auto operator""_l(long double l) { return volume(l); } +constexpr auto operator"" q_l(unsigned long long l) { return volume(l); } +constexpr auto operator"" q_l(long double l) { return volume(l); } } // namespace literals diff --git a/src/include/units/physical/typographic/length.h b/src/include/units/physical/typographic/length.h index 1584b174..ab58b2ff 100644 --- a/src/include/units/physical/typographic/length.h +++ b/src/include/units/physical/typographic/length.h @@ -36,20 +36,20 @@ struct point_prn : named_scaled_unit(l); } -constexpr auto operator"" pica_comp(long double l) { return si::length(l); } +constexpr auto operator"" q_pica_comp(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_pica_comp(long double l) { return si::length(l); } // pica prn -constexpr auto operator"" pica_prn(unsigned long long l) { return si::length(l); } -constexpr auto operator"" pica_prn(long double l) { return si::length(l); } +constexpr auto operator"" q_pica_prn(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_pica_prn(long double l) { return si::length(l); } // point comp -constexpr auto operator"" point_comp(unsigned long long l) { return si::length(l); } -constexpr auto operator"" point_comp(long double l) { return si::length(l); } +constexpr auto operator"" q_point_comp(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_point_comp(long double l) { return si::length(l); } // point prn -constexpr auto operator"" point_prn(unsigned long long l) { return si::length(l); } -constexpr auto operator"" point_prn(long double l) { return si::length(l); } +constexpr auto operator"" q_point_prn(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_point_prn(long double l) { return si::length(l); } } // namespace literals diff --git a/src/include/units/physical/us/length.h b/src/include/units/physical/us/length.h index 14c468c9..6f1abca0 100644 --- a/src/include/units/physical/us/length.h +++ b/src/include/units/physical/us/length.h @@ -40,16 +40,16 @@ struct mile : named_scaled_unit, us::foot inline namespace literals { // ft -constexpr auto operator"" ft_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" ft_us(long double l) { return si::length(l); } +constexpr auto operator"" q_ft_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_ft_us(long double l) { return si::length(l); } // fathom -constexpr auto operator"" fathom_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" fathom_us(long double l) { return si::length(l); } +constexpr auto operator"" q_fathom_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_fathom_us(long double l) { return si::length(l); } // ft -constexpr auto operator"" mi_us(unsigned long long l) { return si::length(l); } -constexpr auto operator"" mi_us(long double l) { return si::length(l); } +constexpr auto operator"" q_mi_us(unsigned long long l) { return si::length(l); } +constexpr auto operator"" q_mi_us(long double l) { return si::length(l); } } // namespace literals diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index 6c5c89c7..7c213780 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -157,7 +157,7 @@ struct cast_ratio { * * This cast gets the target quantity type to cast to. For example: * - * auto q1 = units::quantity_cast>(1ms); + * auto q1 = units::quantity_cast>(1q_ms); * * @tparam To a target quantity type to cast to */ @@ -182,7 +182,7 @@ template * * This cast gets only the target dimension to cast to. For example: * - * auto q1 = units::quantity_cast(200Gal); + * auto q1 = units::quantity_cast(200q_Gal); * * @tparam ToD a dimension type to use for a target quantity */ @@ -201,7 +201,7 @@ template * * This cast gets only the target unit to cast to. For example: * - * auto q1 = units::quantity_cast(1ms); + * auto q1 = units::quantity_cast(1q_ms); * * @tparam ToU a unit type to use for a target quantity */ @@ -220,7 +220,7 @@ template * * This cast gets only representation to cast to. For example: * - * auto q1 = units::quantity_cast(1ms); + * auto q1 = units::quantity_cast(1q_ms); * * @tparam ToRep a representation type to use for a target quantity */ diff --git a/test/unit_test/runtime/digital_info_test.cpp b/test/unit_test/runtime/digital_info_test.cpp index 0b032a09..09526c1e 100644 --- a/test/unit_test/runtime/digital_info_test.cpp +++ b/test/unit_test/runtime/digital_info_test.cpp @@ -34,25 +34,25 @@ TEST_CASE("operator<< on a data quantity", "[text][ostream]") { SECTION("named unit") { - stream << 64B; + stream << 64q_B; REQUIRE(stream.str() == "64 B"); } SECTION("prefixed coherent unit") { - stream << 256Kib; + stream << 256q_Kib; REQUIRE(stream.str() == "256 Kib"); } SECTION("prefixed non-coherent unit") { - stream << 1024KiB; + stream << 1024q_KiB; REQUIRE(stream.str() == "1024 KiB"); } SECTION("other unit matching prefix") { - stream << 8Kib * 8Kib / 2b; + stream << 8q_Kib * 8q_Kib / 2q_b; REQUIRE(stream.str() == "32 Mib"); } } diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index b73b4ef0..a72ee604c 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -46,7 +46,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { SECTION("integral representation") { - const auto q = 60W; + const auto q = 60q_W; stream << q; SECTION("iostream") @@ -67,7 +67,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("floating-point representation") { - const auto q = 1023.5Pa; + const auto q = 1023.5q_Pa; stream << q; SECTION("iostream") @@ -89,7 +89,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("quantity with a predefined prefixed unit") { - const auto q = 125us; + const auto q = 125q_us; stream << q; SECTION("iostream") @@ -159,7 +159,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { SECTION("acceleration") { - const auto q = 20m / 2s / 1s; + const auto q = 20q_m / 2q_s / 1q_s; stream << q; SECTION("iostream") @@ -180,7 +180,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("volume") { - const auto q = 2m * 1m * 1m; + const auto q = 2q_m * 1q_m * 1q_m; stream << q; SECTION("iostream") @@ -201,7 +201,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("surface tension") { - const auto q = 20N / 2m; + const auto q = 20q_N / 2q_m; stream << q; SECTION("iostream") @@ -225,12 +225,12 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { SECTION("velocity") { - const auto q = 20km / 2h; + const auto q = 20q_km / 2q_h; stream << q; SECTION("iostream") { - CHECK(stream.str() == "10 km/h"); + CHECK(stream.str() == "10.q_km/h"); } SECTION("fmt with default format {} on a quantity") @@ -272,7 +272,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { SECTION("unit::ratio as an SI prefix for a dimension with a special symbol") { - const auto q = 4N * 2cm; + const auto q = 4q_N * 2q_cm; stream << q; SECTION("iostream") @@ -293,7 +293,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio for a dimension without a special symbol") { - const auto q = 2cm * 2m * 2m; + const auto q = 2q_cm * 2q_m * 2q_m; stream << q; SECTION("iostream") @@ -314,7 +314,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num != 1 && unit::ratio::den == 1") { - const auto q = 4 * 2min / (2s * 2s); + const auto q = 4 * 2q_min / (2q_s * 2q_s); stream << q; SECTION("iostream") @@ -335,7 +335,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num == 1 && unit::ratio::den != 1") { - const auto q = 20_J / 2min; + const auto q = 20q_J / 2q_min; stream << q; SECTION("iostream") @@ -356,7 +356,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num != 1 && unit::ratio::den != 1") { - const auto q = 60kJ / 2min; + const auto q = 60q_kJ / 2q_min; stream << q; SECTION("iostream") @@ -382,7 +382,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { SECTION("SI base units") { - const auto q = 2s * 2m * 2kg; + const auto q = 2q_s * 2q_m * 2q_kg; stream << q; SECTION("iostream") @@ -403,7 +403,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("CGS base units") { - const auto q = 2s * cgs::length(2) * cgs::mass(2); + const auto q = 2q_s * cgs::length(2) * cgs::mass(2); stream << q; SECTION("iostream") @@ -425,7 +425,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio as an SI prefix") { - const auto q = 4km * 2s; + const auto q = 4q_km * 2q_s; stream << q; SECTION("iostream") @@ -446,7 +446,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num != 1 && unit::ratio::den == 1") { - const auto q = 4kg * 2min / (2s * 2s); + const auto q = 4q_kg * 2q_min / (2q_s * 2q_s); stream << q; SECTION("iostream") @@ -467,7 +467,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num == 1 && unit::ratio::den != 1") { - const auto q = 20kg / 2min; + const auto q = 20q_kg / 2q_min; stream << q; SECTION("iostream") @@ -488,7 +488,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("CGS base units") { - const auto q = 2s * cgs::length(2) * cgs::mass(2); + const auto q = 2q_s * cgs::length(2) * cgs::mass(2); stream << q; SECTION("iostream") @@ -509,7 +509,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("unit::ratio::num != 1 && unit::ratio::den != 1") { - const auto q = 60min / 2km; + const auto q = 60q_min / 2q_km; stream << q; SECTION("iostream") @@ -530,7 +530,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("exp::num == 1 && exp::den == 1") { - const auto q = 4m * 2s; + const auto q = 4q_m * 2q_s; stream << q; SECTION("iostream") @@ -551,7 +551,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("exp::num == 2 && exp::den == 1 for positive exponent") { - const auto q = 4m * 2s * 2s; + const auto q = 4q_m * 2q_s * 2q_s; stream << q; SECTION("iostream") @@ -572,7 +572,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("exp::num == 2 && exp::den == 1 for negative exponent (first dimension)") { - const auto q = 8s / 2m / 2m; + const auto q = 8q_s / 2q_m / 2q_m; stream << q; SECTION("iostream") @@ -593,7 +593,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("exp::num == 2 && exp::den == 1 for negative exponent (not first dimension)") { - const auto q = 8m / 2kg / 2kg; + const auto q = 8q_m / 2q_kg / 2q_kg; stream << q; SECTION("iostream") @@ -614,7 +614,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("fractional positive exponent") { - const auto q = sqrt(9m); + const auto q = sqrt(9q_m); stream << q; SECTION("iostream") @@ -635,7 +635,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("fractional negative exponent") { - const auto q = sqrt(9 / 1m); + const auto q = sqrt(9 / 1q_m); stream << q; SECTION("iostream") @@ -662,12 +662,12 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text] { SECTION("positive value") { - CHECK(fmt::format("{:%Q}", 123kmph) == "123"); + CHECK(fmt::format("{:%Q}", 123q_kmph) == "123"); } SECTION("negative value") { - CHECK(fmt::format("{:%Q}", 5m - 10m) == "-5"); + CHECK(fmt::format("{:%Q}", 5q_m - 10q_m) == "-5"); } } @@ -675,12 +675,12 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text] { SECTION("positive value") { - CHECK(fmt::format("{:%Q}", 221.km / 2h) == "110.5"); + CHECK(fmt::format("{:%Q}", 221.q_km / 2q_h) == "110.5"); } SECTION("negative value") { - CHECK(fmt::format("{:%Q}", 3.14m - 10m) == "-6.86"); + CHECK(fmt::format("{:%Q}", 3.14q_m - 10q_m) == "-6.86"); } SECTION("nan") @@ -702,39 +702,39 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text] TEST_CASE("format string with only %q should print quantity unit symbol only", "[text][fmt]") { - CHECK(fmt::format("{:%q}", 123kmph) == "km/h"); + CHECK(fmt::format("{:%q}", 123q_kmph) == "km/h"); } TEST_CASE("%q an %Q can be put anywhere in a format string", "[text][fmt]") { SECTION("no space") { - CHECK(fmt::format("{:%Q%q}", 123kmph) == "123km/h"); + CHECK(fmt::format("{:%Q%q}", 123q_kmph) == "123q_km/h"); } SECTION("separator") { - CHECK(fmt::format("{:%Q###%q}", 123kmph) == "123###km/h"); + CHECK(fmt::format("{:%Q###%q}", 123q_kmph) == "123###km/h"); } SECTION("opposite order") { - CHECK(fmt::format("{:%q %Q}", 123kmph) == "km/h 123"); + CHECK(fmt::format("{:%q %Q}", 123q_kmph) == "km/h 123"); } SECTION("tabulator") { - CHECK(fmt::format("{:%Q%t%q}", 123kmph) == "123\tkm/h"); + CHECK(fmt::format("{:%Q%t%q}", 123q_kmph) == "123\tkm/h"); } SECTION("new line") { - CHECK(fmt::format("{:%Q%n%q}", 123kmph) == "123\nkm/h"); + CHECK(fmt::format("{:%Q%n%q}", 123q_kmph) == "123\nkm/h"); } SECTION("% sign") { - CHECK(fmt::format("{:%Q%% %q}", 123kmph) == "123% km/h"); + CHECK(fmt::format("{:%Q%% %q}", 123q_kmph) == "123% km/h"); } } @@ -742,50 +742,50 @@ TEST_CASE("fill and align specification", "[text][fmt]") { SECTION("default format {} on a quantity") { - CHECK(fmt::format("|{:0}|", 123m) == "|123 m|"); - CHECK(fmt::format("|{:10}|", 123m) == "| 123 m|"); - CHECK(fmt::format("|{:<10}|", 123m) == "|123 m |"); - CHECK(fmt::format("|{:>10}|", 123m) == "| 123 m|"); - CHECK(fmt::format("|{:^10}|", 123m) == "| 123 m |"); - CHECK(fmt::format("|{:*<10}|", 123m) == "|123 m*****|"); - CHECK(fmt::format("|{:*>10}|", 123m) == "|*****123 m|"); - CHECK(fmt::format("|{:*^10}|", 123m) == "|**123 m***|"); + CHECK(fmt::format("|{:0}|", 123q_m) == "|123 m|"); + CHECK(fmt::format("|{:10}|", 123q_m) == "| 123 m|"); + CHECK(fmt::format("|{:<10}|", 123q_m) == "|123 m |"); + CHECK(fmt::format("|{:>10}|", 123q_m) == "| 123 m|"); + CHECK(fmt::format("|{:^10}|", 123q_m) == "| 123 m |"); + CHECK(fmt::format("|{:*<10}|", 123q_m) == "|123 m*****|"); + CHECK(fmt::format("|{:*>10}|", 123q_m) == "|*****123 m|"); + CHECK(fmt::format("|{:*^10}|", 123q_m) == "|**123 m***|"); } SECTION("full format {:%Q %q} on a quantity") { - CHECK(fmt::format("|{:0%Q%q}|", 123m) == "|123m|"); - CHECK(fmt::format("|{:10%Q%q}|", 123m) == "| 123m|"); - CHECK(fmt::format("|{:<10%Q%q}|", 123m) == "|123m |"); - CHECK(fmt::format("|{:>10%Q%q}|", 123m) == "| 123m|"); - CHECK(fmt::format("|{:^10%Q%q}|", 123m) == "| 123m |"); - CHECK(fmt::format("|{:*<10%Q%q}|", 123m) == "|123m******|"); - CHECK(fmt::format("|{:*>10%Q%q}|", 123m) == "|******123m|"); - CHECK(fmt::format("|{:*^10%Q%q}|", 123m) == "|***123m***|"); + CHECK(fmt::format("|{:0%Q%q}|", 123q_m) == "|123q_m|"); + CHECK(fmt::format("|{:10%Q%q}|", 123q_m) == "| 123q_m|"); + CHECK(fmt::format("|{:<10%Q%q}|", 123q_m) == "|123q_m |"); + CHECK(fmt::format("|{:>10%Q%q}|", 123q_m) == "| 123q_m|"); + CHECK(fmt::format("|{:^10%Q%q}|", 123q_m) == "| 123q_m |"); + CHECK(fmt::format("|{:*<10%Q%q}|", 123q_m) == "|123q_m******|"); + CHECK(fmt::format("|{:*>10%Q%q}|", 123q_m) == "|******123q_m|"); + CHECK(fmt::format("|{:*^10%Q%q}|", 123q_m) == "|***123q_m***|"); } SECTION("value only format {:%Q} on a quantity") { - CHECK(fmt::format("|{:0%Q}|", 123m) == "|123|"); - CHECK(fmt::format("|{:10%Q}|", 123m) == "| 123|"); - CHECK(fmt::format("|{:<10%Q}|", 123m) == "|123 |"); - CHECK(fmt::format("|{:>10%Q}|", 123m) == "| 123|"); - CHECK(fmt::format("|{:^10%Q}|", 123m) == "| 123 |"); - CHECK(fmt::format("|{:*<10%Q}|", 123m) == "|123*******|"); - CHECK(fmt::format("|{:*>10%Q}|", 123m) == "|*******123|"); - CHECK(fmt::format("|{:*^10%Q}|", 123m) == "|***123****|"); + CHECK(fmt::format("|{:0%Q}|", 123q_m) == "|123|"); + CHECK(fmt::format("|{:10%Q}|", 123q_m) == "| 123|"); + CHECK(fmt::format("|{:<10%Q}|", 123q_m) == "|123 |"); + CHECK(fmt::format("|{:>10%Q}|", 123q_m) == "| 123|"); + CHECK(fmt::format("|{:^10%Q}|", 123q_m) == "| 123 |"); + CHECK(fmt::format("|{:*<10%Q}|", 123q_m) == "|123*******|"); + CHECK(fmt::format("|{:*>10%Q}|", 123q_m) == "|*******123|"); + CHECK(fmt::format("|{:*^10%Q}|", 123q_m) == "|***123****|"); } SECTION("symbol only format {:%q} on a quantity") { - CHECK(fmt::format("|{:0%q}|", 123m) == "|m|"); - CHECK(fmt::format("|{:10%q}|", 123m) == "|m |"); - CHECK(fmt::format("|{:<10%q}|", 123m) == "|m |"); - CHECK(fmt::format("|{:>10%q}|", 123m) == "| m|"); - CHECK(fmt::format("|{:^10%q}|", 123m) == "| m |"); - CHECK(fmt::format("|{:*<10%q}|", 123m) == "|m*********|"); - CHECK(fmt::format("|{:*>10%q}|", 123m) == "|*********m|"); - CHECK(fmt::format("|{:*^10%q}|", 123m) == "|****m*****|"); + CHECK(fmt::format("|{:0%q}|", 123q_m) == "|m|"); + CHECK(fmt::format("|{:10%q}|", 123q_m) == "|m |"); + CHECK(fmt::format("|{:<10%q}|", 123q_m) == "|m |"); + CHECK(fmt::format("|{:>10%q}|", 123q_m) == "| m|"); + CHECK(fmt::format("|{:^10%q}|", 123q_m) == "| m |"); + CHECK(fmt::format("|{:*<10%q}|", 123q_m) == "|m*********|"); + CHECK(fmt::format("|{:*>10%q}|", 123q_m) == "|*********m|"); + CHECK(fmt::format("|{:*^10%q}|", 123q_m) == "|****m*****|"); } } @@ -796,24 +796,24 @@ TEST_CASE("sign specification", "[text][fmt]") SECTION("default format {} on a quantity") { - CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", 1m) == "1 m,+1 m,1 m, 1 m"); - CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", -1m) == "-1 m,-1 m,-1 m,-1 m"); + CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", 1q_m) == "1 m,+1 m,1 m, 1 m"); + CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", -1q_m) == "-1 m,-1 m,-1 m,-1 m"); CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", inf) == "inf m,+inf m,inf m, inf m"); CHECK(fmt::format("{0:},{0:+},{0:-},{0: }", nan) == "nan m,+nan m,nan m, nan m"); } SECTION("full format {:%Q %q} on a quantity") { - CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", 1m) == "1m,+1m,1m, 1m"); - CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", -1m) == "-1m,-1m,-1m,-1m"); + CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", 1q_m) == "1q_m,+1q_m,1q_m, 1q_m"); + CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", -1q_m) == "-1q_m,-1q_m,-1q_m,-1q_m"); CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", inf) == "infm,+infm,infm, infm"); CHECK(fmt::format("{0:%Q%q},{0:+%Q%q},{0:-%Q%q},{0: %Q%q}", nan) == "nanm,+nanm,nanm, nanm"); } SECTION("value only format {:%Q} on a quantity") { - CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", 1m) == "1,+1,1, 1"); - CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", -1m) == "-1,-1,-1,-1"); + CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", 1q_m) == "1,+1,1, 1"); + CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", -1q_m) == "-1,-1,-1,-1"); CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", inf) == "inf,+inf,inf, inf"); CHECK(fmt::format("{0:%Q},{0:+%Q},{0:-%Q},{0: %Q}", nan) == "nan,+nan,nan, nan"); } @@ -821,8 +821,8 @@ TEST_CASE("sign specification", "[text][fmt]") TEST_CASE("sign specification for unit only", "[text][fmt][exception]") { - CHECK_THROWS_MATCHES(fmt::format("{:+%q}", 1m), fmt::format_error, Message("sign not allowed for a quantity unit")); - CHECK_THROWS_MATCHES(fmt::format("{:-%q}", 1m), fmt::format_error, Message("sign not allowed for a quantity unit")); + CHECK_THROWS_MATCHES(fmt::format("{:+%q}", 1q_m), fmt::format_error, Message("sign not allowed for a quantity unit")); + CHECK_THROWS_MATCHES(fmt::format("{:-%q}", 1q_m), fmt::format_error, Message("sign not allowed for a quantity unit")); } @@ -830,35 +830,35 @@ TEST_CASE("precision specification", "[text][fmt]") { SECTION("default format {} on a quantity") { - CHECK(fmt::format("{:.1}", 1.2345m) == "1.2 m"); - CHECK(fmt::format("{:.0}", 1.2345m) == "1 m"); - CHECK(fmt::format("{:.2}", 1.2345m) == "1.23 m"); - CHECK(fmt::format("{:.3}", 1.2345m) == "1.235 m"); - CHECK(fmt::format("{:.4}", 1.2345m) == "1.2345 m"); - CHECK(fmt::format("{:.5}", 1.2345m) == "1.23450 m"); - CHECK(fmt::format("{:.10}", 1.2345m) == "1.2345000000 m"); + CHECK(fmt::format("{:.1}", 1.2345q_m) == "1.2 m"); + CHECK(fmt::format("{:.0}", 1.2345q_m) == "1 m"); + CHECK(fmt::format("{:.2}", 1.2345q_m) == "1.23 m"); + CHECK(fmt::format("{:.3}", 1.2345q_m) == "1.235 m"); + CHECK(fmt::format("{:.4}", 1.2345q_m) == "1.2345 m"); + CHECK(fmt::format("{:.5}", 1.2345q_m) == "1.23450 m"); + CHECK(fmt::format("{:.10}", 1.2345q_m) == "1.2345000000 m"); } SECTION("full format {:%Q %q} on a quantity") { - CHECK(fmt::format("{:.0%Q %q}", 1.2345m) == "1 m"); - CHECK(fmt::format("{:.1%Q %q}", 1.2345m) == "1.2 m"); - CHECK(fmt::format("{:.2%Q %q}", 1.2345m) == "1.23 m"); - CHECK(fmt::format("{:.3%Q %q}", 1.2345m) == "1.235 m"); - CHECK(fmt::format("{:.4%Q %q}", 1.2345m) == "1.2345 m"); - CHECK(fmt::format("{:.5%Q %q}", 1.2345m) == "1.23450 m"); - CHECK(fmt::format("{:.10%Q %q}", 1.2345m) == "1.2345000000 m"); + CHECK(fmt::format("{:.0%Q %q}", 1.2345q_m) == "1 m"); + CHECK(fmt::format("{:.1%Q %q}", 1.2345q_m) == "1.2 m"); + CHECK(fmt::format("{:.2%Q %q}", 1.2345q_m) == "1.23 m"); + CHECK(fmt::format("{:.3%Q %q}", 1.2345q_m) == "1.235 m"); + CHECK(fmt::format("{:.4%Q %q}", 1.2345q_m) == "1.2345 m"); + CHECK(fmt::format("{:.5%Q %q}", 1.2345q_m) == "1.23450 m"); + CHECK(fmt::format("{:.10%Q %q}", 1.2345q_m) == "1.2345000000 m"); } SECTION("value only format {:%Q} on a quantity") { - CHECK(fmt::format("{:.0%Q}", 1.2345m) == "1"); - CHECK(fmt::format("{:.1%Q}", 1.2345m) == "1.2"); - CHECK(fmt::format("{:.2%Q}", 1.2345m) == "1.23"); - CHECK(fmt::format("{:.3%Q}", 1.2345m) == "1.235"); - CHECK(fmt::format("{:.4%Q}", 1.2345m) == "1.2345"); - CHECK(fmt::format("{:.5%Q}", 1.2345m) == "1.23450"); - CHECK(fmt::format("{:.10%Q}", 1.2345m) == "1.2345000000"); + CHECK(fmt::format("{:.0%Q}", 1.2345q_m) == "1"); + CHECK(fmt::format("{:.1%Q}", 1.2345q_m) == "1.2"); + CHECK(fmt::format("{:.2%Q}", 1.2345q_m) == "1.23"); + CHECK(fmt::format("{:.3%Q}", 1.2345q_m) == "1.235"); + CHECK(fmt::format("{:.4%Q}", 1.2345q_m) == "1.2345"); + CHECK(fmt::format("{:.5%Q}", 1.2345q_m) == "1.23450"); + CHECK(fmt::format("{:.10%Q}", 1.2345q_m) == "1.2345000000"); } } @@ -866,17 +866,17 @@ TEST_CASE("precision specification for integral representation should throw", "[ { SECTION("default format {} on a quantity") { - REQUIRE_THROWS_MATCHES(fmt::format("{:.1}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(fmt::format("{:.1}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation")); } SECTION("full format {:%Q %q} on a quantity") { - REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q %q}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q %q}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation")); } SECTION("value only format {:%Q} on a quantity") { - REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q}", 1m), fmt::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(fmt::format("{:.1%Q}", 1q_m), fmt::format_error, Message("precision not allowed for integral quantity representation")); } } @@ -890,47 +890,47 @@ TEST_CASE("quantity_cast", "[text][ostream]") SECTION("int to double representation") { - const auto q = 121km / 2h; + const auto q = 121q_km / 2q_h; SECTION("original") { stream << q; - CHECK(stream.str() == "60 km/h"); + CHECK(stream.str() == "60.q_km/h"); } SECTION("int") { stream << quantity_cast(q); - CHECK(stream.str() == "60 km/h"); + CHECK(stream.str() == "60.q_km/h"); } SECTION("double") { stream << quantity_cast(q); - CHECK(stream.str() == "60 km/h"); + CHECK(stream.str() == "60.q_km/h"); } } SECTION("double to int representation") { - const auto q = 121.km / 2h; + const auto q = 121.q_km / 2q_h; SECTION("original") { stream << q; - CHECK(stream.str() == "60.5 km/h"); + CHECK(stream.str() == "60.5.q_km/h"); } SECTION("int") { stream << quantity_cast(q); - CHECK(stream.str() == "60 km/h"); + CHECK(stream.str() == "60.q_km/h"); } SECTION("double") { stream << quantity_cast(q); - CHECK(stream.str() == "60.5 km/h"); + CHECK(stream.str() == "60.5.q_km/h"); } } } diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 28966448..cdb9db30 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -51,123 +51,123 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") { SECTION("time") { - CHECK(fmt::format("{}", 1ns) == "1 ns"); - CHECK(fmt::format("{}", 1us) == "1 µs"); - CHECK(fmt::format("{}", 1ms) == "1 ms"); + CHECK(fmt::format("{}", 1q_ns) == "1 ns"); + CHECK(fmt::format("{}", 1q_us) == "1 µs"); + CHECK(fmt::format("{}", 1q_ms) == "1 ms"); } SECTION("length") { - CHECK(fmt::format("{}", 1mm) == "1 mm"); - CHECK(fmt::format("{}", 1cm) == "1 cm"); - CHECK(fmt::format("{}", 1km) == "1 km"); - CHECK(fmt::format("{}", 1ft) == "1 ft"); - CHECK(fmt::format("{}", 1ft_us) == "1 ft(us)"); - CHECK(fmt::format("{}", 1yd) == "1 yd"); - CHECK(fmt::format("{}", 1in) == "1 in"); - CHECK(fmt::format("{}", 1fathom) == "1 fathom"); - CHECK(fmt::format("{}", 1fathom_us) == "1 fathom(us)"); - CHECK(fmt::format("{}", 1mi) == "1 mi"); - CHECK(fmt::format("{}", 1mi_us) == "1 mi(us)"); - CHECK(fmt::format("{}", 1naut_mi) == "1 mi(naut)"); - CHECK(fmt::format("{}", 1ch) == "1 ch"); - CHECK(fmt::format("{}", 1rd) == "1 rd"); - CHECK(fmt::format("{}", 1thou) == "1 thou"); - CHECK(fmt::format("{}", 1pc) == "1 pc"); - CHECK(fmt::format("{}", 1ly) == "1 ly"); - CHECK(fmt::format("{}", 1pc) == "1 pc"); - CHECK(fmt::format("{}", 1angstrom) == "1 angstrom"); - CHECK(fmt::format("{}", 1au) == "1 au"); - CHECK(fmt::format("{}", 1pica_comp) == "1 pica(comp)"); - CHECK(fmt::format("{}", 1pica_prn) == "1 pica(prn)"); - CHECK(fmt::format("{}", 1point_comp) == "1 point(comp)"); - CHECK(fmt::format("{}", 1point_prn) == "1 point(prn)"); + CHECK(fmt::format("{}", 1q_mm) == "1 mm"); + CHECK(fmt::format("{}", 1q_cm) == "1 cm"); + CHECK(fmt::format("{}", 1q_km) == "1.q_km"); + CHECK(fmt::format("{}", 1q_ft) == "1 ft"); + CHECK(fmt::format("{}", 1q_ft_us) == "1 ft(us)"); + CHECK(fmt::format("{}", 1q_yd) == "1 yd"); + CHECK(fmt::format("{}", 1q_in) == "1 in"); + CHECK(fmt::format("{}", 1q_fathom) == "1 fathom"); + CHECK(fmt::format("{}", 1q_fathom_us) == "1 fathom(us)"); + CHECK(fmt::format("{}", 1q_mi) == "1 mi"); + CHECK(fmt::format("{}", 1q_mi_us) == "1 mi(us)"); + CHECK(fmt::format("{}", 1q_naut_mi) == "1 mi(naut)"); + CHECK(fmt::format("{}", 1q_ch) == "1 ch"); + CHECK(fmt::format("{}", 1q_rd) == "1 rd"); + CHECK(fmt::format("{}", 1q_thou) == "1 thou"); + CHECK(fmt::format("{}", 1q_pc) == "1 pc"); + CHECK(fmt::format("{}", 1q_ly) == "1 ly"); + CHECK(fmt::format("{}", 1q_pc) == "1 pc"); + CHECK(fmt::format("{}", 1q_angstrom) == "1 angstrom"); + CHECK(fmt::format("{}", 1q_au) == "1 au"); + CHECK(fmt::format("{}", 1q_pica_comp) == "1 pica(comp)"); + CHECK(fmt::format("{}", 1q_pica_prn) == "1 pica(prn)"); + CHECK(fmt::format("{}", 1q_point_comp) == "1 point(comp)"); + CHECK(fmt::format("{}", 1q_point_prn) == "1 point(prn)"); } SECTION("mass") { - CHECK(fmt::format("{}", 1kg) == "1 kg"); + CHECK(fmt::format("{}", 1q_kg) == "1 kg"); } SECTION("area") { - CHECK(fmt::format("{}", 1m2) == "1 m²"); - CHECK(fmt::format("{}", 1mm2) == "1 mm²"); - CHECK(fmt::format("{}", 1cm2) == "1 cm²"); - CHECK(fmt::format("{}", 1km2) == "1 km²"); - CHECK(fmt::format("{}", 1ft2) == "1 ft²"); + CHECK(fmt::format("{}", 1q_m2) == "1 m²"); + CHECK(fmt::format("{}", 1q_mm2) == "1 mm²"); + CHECK(fmt::format("{}", 1q_cm2) == "1 cm²"); + CHECK(fmt::format("{}", 1q_km2) == "1.q_km²"); + CHECK(fmt::format("{}", 1q_ft2) == "1 ft²"); } SECTION("density") { - CHECK(fmt::format("{}", 1kgpm3) == "1 kg/m³"); + CHECK(fmt::format("{}", 1q_kgpm3) == "1 kg/m³"); } SECTION("resistance") { - CHECK(fmt::format("{}", 1_R) == "1 Ω"); - CHECK(fmt::format("{}", 1kR) == "1 kΩ"); - CHECK(fmt::format("{}", 1mR) == "1 mΩ"); - CHECK(fmt::format("{}", 1MR) == "1 MΩ"); + CHECK(fmt::format("{}", 1q_R) == "1 Ω"); + CHECK(fmt::format("{}", 1q_kR) == "1 kΩ"); + CHECK(fmt::format("{}", 1q_mR) == "1 mΩ"); + CHECK(fmt::format("{}", 1q_MR) == "1 MΩ"); } SECTION("voltage") { - CHECK(fmt::format("{}", 1V) == "1 V"); - CHECK(fmt::format("{}", 1mV) == "1 mV"); - CHECK(fmt::format("{}", 1uV) == "1 µV"); - CHECK(fmt::format("{}", 1nV) == "1 nV"); - CHECK(fmt::format("{}", 1pV) == "1 pV"); + CHECK(fmt::format("{}", 1q_V) == "1 V"); + CHECK(fmt::format("{}", 1q_mV) == "1 mV"); + CHECK(fmt::format("{}", 1q_uV) == "1 µV"); + CHECK(fmt::format("{}", 1q_nV) == "1 nV"); + CHECK(fmt::format("{}", 1q_pV) == "1 pV"); } SECTION("volume") { - CHECK(fmt::format("{}", 1m3) == "1 m³"); - CHECK(fmt::format("{}", 1mm3) == "1 mm³"); - CHECK(fmt::format("{}", 1cm3) == "1 cm³"); - CHECK(fmt::format("{}", 1km3) == "1 km³"); - CHECK(fmt::format("{}", 1ft3) == "1 ft³"); + CHECK(fmt::format("{}", 1q_m3) == "1 m³"); + CHECK(fmt::format("{}", 1q_mm3) == "1 mm³"); + CHECK(fmt::format("{}", 1q_cm3) == "1 cm³"); + CHECK(fmt::format("{}", 1q_km3) == "1.q_km³"); + CHECK(fmt::format("{}", 1q_ft3) == "1 ft³"); } SECTION("frequency") { - CHECK(fmt::format("{}", 1mHz) == "1 mHz"); - CHECK(fmt::format("{}", 1kHz) == "1 kHz"); - CHECK(fmt::format("{}", 1MHz) == "1 MHz"); - CHECK(fmt::format("{}", 1GHz) == "1 GHz"); - CHECK(fmt::format("{}", 1THz) == "1 THz"); + CHECK(fmt::format("{}", 1q_mHz) == "1 mHz"); + CHECK(fmt::format("{}", 1q_kHz) == "1 kHz"); + CHECK(fmt::format("{}", 1q_MHz) == "1 MHz"); + CHECK(fmt::format("{}", 1q_GHz) == "1 GHz"); + CHECK(fmt::format("{}", 1q_THz) == "1 THz"); } SECTION("velocity") { - CHECK(fmt::format("{}", 1mps) == "1 m/s"); - CHECK(fmt::format("{}", 1kmph) == "1 km/h"); - CHECK(fmt::format("{}", 1mph) == "1 mi/h"); + CHECK(fmt::format("{}", 1q_mps) == "1 m/s"); + CHECK(fmt::format("{}", 1q_kmph) == "1.q_km/h"); + CHECK(fmt::format("{}", 1q_mph) == "1 mi/h"); } SECTION("acceleration") { - CHECK(fmt::format("{}", 1mps2) == "1 m/s²"); + CHECK(fmt::format("{}", 1q_mps2) == "1 m/s²"); } SECTION("energy") { - CHECK(fmt::format("{}", 1mJ) == "1 mJ"); - CHECK(fmt::format("{}", 1kJ) == "1 kJ"); - CHECK(fmt::format("{}", 1MJ) == "1 MJ"); - CHECK(fmt::format("{}", 1GJ) == "1 GJ"); + CHECK(fmt::format("{}", 1q_mJ) == "1 mJ"); + CHECK(fmt::format("{}", 1q_kJ) == "1 kJ"); + CHECK(fmt::format("{}", 1q_MJ) == "1 MJ"); + CHECK(fmt::format("{}", 1q_GJ) == "1 GJ"); } SECTION("power") { - CHECK(fmt::format("{}", 1mW) == "1 mW"); - CHECK(fmt::format("{}", 1kW) == "1 kW"); - CHECK(fmt::format("{}", 1MW) == "1 MW"); - CHECK(fmt::format("{}", 1GW) == "1 GW"); + CHECK(fmt::format("{}", 1q_mW) == "1 mW"); + CHECK(fmt::format("{}", 1q_kW) == "1 kW"); + CHECK(fmt::format("{}", 1q_MW) == "1 MW"); + CHECK(fmt::format("{}", 1q_GW) == "1 GW"); } SECTION("surface tension") { - CHECK(fmt::format("{}", 1Npm) == "1 N/m"); + CHECK(fmt::format("{}", 1q_Npm) == "1 N/m"); } } diff --git a/test/unit_test/runtime/math_test.cpp b/test/unit_test/runtime/math_test.cpp index dc0e6442..0123a174 100644 --- a/test/unit_test/runtime/math_test.cpp +++ b/test/unit_test/runtime/math_test.cpp @@ -33,23 +33,23 @@ using namespace units::si; TEST_CASE("'pow()' on quantity changes the value and the dimension accordingly", "[math][pow]") { SECTION ("'pow<0>(q)' returns '1'") { - CHECK(pow<0>(2m) == 1); + CHECK(pow<0>(2q_m) == 1); } SECTION ("'pow<1>(q)' returns 'q'") { - CHECK(pow<1>(2m) == 2m); + CHECK(pow<1>(2q_m) == 2q_m); } SECTION ("'pow<2>(q)' squares both the value and a dimension") { - CHECK(pow<2>(2m) == 4m2); + CHECK(pow<2>(2q_m) == 4q_m2); } SECTION ("'pow<3>(q)' cubes both the value and a dimension") { - CHECK(pow<3>(2m) == 8m3); + CHECK(pow<3>(2q_m) == 8q_m3); } } TEST_CASE("'sqrt()' on quantity changes the value and the dimension accordingly", "[math][sqrt]") { - REQUIRE(sqrt(4m2) == 2m); + REQUIRE(sqrt(4q_m2) == 2q_m); } diff --git a/test/unit_test/static/cgs_test.cpp b/test/unit_test/static/cgs_test.cpp index dbf8a779..bf1bcc9a 100644 --- a/test/unit_test/static/cgs_test.cpp +++ b/test/unit_test/static/cgs_test.cpp @@ -50,17 +50,17 @@ static_assert(centimetre::symbol == "cm"); // velocity -static_assert(10cm / 5s == 2cmps); -static_assert(10cm / 2cmps == 5s); -static_assert(10cm == 2cmps * 5s); +static_assert(10q_cm / 5q_s == 2q_cmps); +static_assert(10q_cm / 2q_cmps == 5q_s); +static_assert(10q_cm == 2q_cmps * 5q_s); static_assert(detail::unit_text() == "cm/s"); // area static_assert(std::is_same_v::ratio>, ratio<1>>); -static_assert(1cm * 1cm == 1cm2); -static_assert(100cm2 / 10cm == 10cm); +static_assert(1q_cm * 1q_cm == 1q_cm2); +static_assert(100q_cm2 / 10q_cm == 10q_cm); static_assert(detail::unit_text() == "cm²"); @@ -68,35 +68,35 @@ static_assert(detail::unit_text() == "cm²"); // acceleration -static_assert(10cmps / 10s == 1Gal); -static_assert(10cmps / 1Gal == 10s); -static_assert(1Gal * 10s == 10cmps); +static_assert(10q_cmps / 10q_s == 1q_Gal); +static_assert(10q_cmps / 1q_Gal == 10q_s); +static_assert(1q_Gal * 10q_s == 10q_cmps); // force -static_assert(10g * 10Gal == 100dyn); -static_assert(100dyn / 10g == 10Gal); -static_assert(100dyn / 10Gal == 10g); +static_assert(10q_g * 10q_Gal == 100q_dyn); +static_assert(100q_dyn / 10q_g == 10q_Gal); +static_assert(100q_dyn / 10q_Gal == 10q_g); // pressure -static_assert(10dyn / 10cm2 == 1Ba); -static_assert(10dyn / 1Ba == 10cm2); -static_assert(1Ba * 10cm2 == 10dyn); +static_assert(10q_dyn / 10q_cm2 == 1q_Ba); +static_assert(10q_dyn / 1q_Ba == 10q_cm2); +static_assert(1q_Ba * 10q_cm2 == 10q_dyn); // energy -static_assert(10dyn * 10cm == 100_erg); -static_assert(100_erg / 10cm == 10dyn); -static_assert(100_erg / 10dyn == 10cm); +static_assert(10q_dyn * 10q_cm == 100q_erg); +static_assert(100q_erg / 10q_cm == 10q_dyn); +static_assert(100q_erg / 10q_dyn == 10q_cm); /* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */ // power -static_assert(10_erg / 10s == 1_ergps); -static_assert(1_ergps * 10s == 10_erg); -static_assert(10_erg / 1_ergps == 10s); +static_assert(10q_erg / 10q_s == 1q_ergps); +static_assert(1q_ergps * 10q_s == 10q_erg); +static_assert(10q_erg / 1q_ergps == 10q_s); static_assert(detail::unit_text() == "erg/s"); diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index 3c0ff742..08921a8c 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -62,7 +62,7 @@ namespace { struct kilogram_per_second : unit {}; struct dim_mass_rate : derived_dimension, units::exp> {}; struct kilogram_per_hour : deduced_unit {}; -constexpr auto a = 1kg / 1h; +constexpr auto a = 1q_kg / 1q_h; static_assert(std::is_same_v); } diff --git a/test/unit_test/static/data_test.cpp b/test/unit_test/static/data_test.cpp index 14b483b2..75ce5d86 100644 --- a/test/unit_test/static/data_test.cpp +++ b/test/unit_test/static/data_test.cpp @@ -31,17 +31,17 @@ using namespace units::data; // information -static_assert(1B == 8b); -static_assert(1024b == 1Kib); -static_assert(1024B == 1KiB); -static_assert(8 * 1024b == 1KiB); -static_assert(8 * 1Kib == 1KiB); +static_assert(1q_B == 8q_b); +static_assert(1024q_b == 1q_Kib); +static_assert(1024q_B == 1q_KiB); +static_assert(8 * 1024q_b == 1q_KiB); +static_assert(8 * 1q_Kib == 1q_KiB); -static_assert(1Kib == 1024b); -static_assert(1Mib == 1024Kib); -static_assert(1Gib == 1024Mib); -static_assert(1Tib == 1024Gib); -static_assert(1Pib == 1024Tib); +static_assert(1q_Kib == 1024q_b); +static_assert(1q_Mib == 1024q_Kib); +static_assert(1q_Gib == 1024q_Mib); +static_assert(1q_Tib == 1024q_Gib); +static_assert(1q_Pib == 1024q_Tib); // bitrate diff --git a/test/unit_test/static/math_test.cpp b/test/unit_test/static/math_test.cpp index 6d9d35ba..fa4a3b2e 100644 --- a/test/unit_test/static/math_test.cpp +++ b/test/unit_test/static/math_test.cpp @@ -30,14 +30,14 @@ namespace { using namespace units::si::literals; using namespace units::international::literals; - static_assert(std::is_same_v(2m)), std::int64_t>); - static_assert(std::is_same_v(2m)), decltype(2m)>); - static_assert(std::is_same_v(2m)), decltype(4m2)>); - static_assert(std::is_same_v(2km)), decltype(4km2)>); - static_assert(std::is_same_v(2ft)), decltype(4ft2)>); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v(2q_m)), std::int64_t>); + static_assert(std::is_same_v(2q_m)), decltype(2q_m)>); + static_assert(std::is_same_v(2q_m)), decltype(4q_m2)>); + static_assert(std::is_same_v(2q_km)), decltype(4q_km2)>); + static_assert(std::is_same_v(2q_ft)), decltype(4q_ft2)>); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); } // namespace diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 9fb129ce..339ae041 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -148,19 +148,19 @@ static_assert(length(3.14).count() == my_double{3.14}); static_assert(length(km).count() == 1000); // static_assert(length(length(3.14)).count() == 3); // should not compile (truncating conversion) -static_assert(length(quantity_cast>(3.14m)).count() == 3); +static_assert(length(quantity_cast>(3.14q_m)).count() == 3); // static_assert(length(length(1000.0)).count() == 1000); // should not compile (truncating conversion) -// static_assert(length(1000.0m).count() == my_int{1000}); // should not compile (truncating conversion) -static_assert(length(1000.0m).count() == 1000.0); +// static_assert(length(1000.0q_m).count() == my_int{1000}); // should not compile (truncating conversion) +static_assert(length(1000.0q_m).count() == 1000.0); static_assert(length(length(1000.0)).count() == 1000.0); -static_assert(length(1000.0m).count() == my_double{1000.0}); +static_assert(length(1000.0q_m).count() == my_double{1000.0}); static_assert(length(km).count() == 1000.0); static_assert(length(km).count() == my_double{1000.0}); -static_assert(length(1km).count() == 1000); -// static_assert(length(1s).count() == 1); // should not compile (different dimensions) -//static_assert(length(1010m).count() == 1); // should not compile (truncating conversion) -static_assert(length(quantity_cast>(1010m)).count() == 1); -static_assert(length(quantity_cast>(1010m)).count() == 1000); +static_assert(length(1q_km).count() == 1000); +// static_assert(length(1q_s).count() == 1); // should not compile (different dimensions) +//static_assert(length(1010q_m).count() == 1); // should not compile (truncating conversion) +static_assert(length(quantity_cast>(1010q_m)).count() == 1); +static_assert(length(quantity_cast>(1010q_m)).count() == 1000); // assignment operator @@ -209,19 +209,19 @@ static_assert([](auto v) { // compound assignment -static_assert((1m += 1m).count() == 2); -static_assert((2m -= 1m).count() == 1); -static_assert((1m *= 2).count() == 2); -static_assert((2m /= 2).count() == 1); -static_assert((7m %= 2).count() == 1); -static_assert((7m %= 2m).count() == 1); +static_assert((1q_m += 1q_m).count() == 2); +static_assert((2q_m -= 1q_m).count() == 1); +static_assert((1q_m *= 2).count() == 2); +static_assert((2q_m /= 2).count() == 1); +static_assert((7q_m %= 2).count() == 1); +static_assert((7q_m %= 2q_m).count() == 1); // static_assert((7.m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types) // static_assert((7.m %= 2).count() == 1); // should not compile (operation not allowed for floating-point types) -// static_assert((7m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types) -static_assert((7m %= 2m).count() == 1); +// static_assert((7q_m %= 2.).count() == 1); // should not compile (operation not allowed for floating-point types) +static_assert((7q_m %= 2q_m).count() == 1); // static_assert((7.m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types) -// static_assert((7.m %= 2m).count() == 1); // should not compile (operation not allowed for floating-point types) -// static_assert((7m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types) +// static_assert((7.m %= 2q_m).count() == 1); // should not compile (operation not allowed for floating-point types) +// static_assert((7q_m %= 2.m).count() == 1); // should not compile (operation not allowed for floating-point types) // non-member arithmetic operators @@ -257,51 +257,51 @@ static_assert(std::is_same_v() / length()), static_assert(std::is_same_v() % short(1)), length>); static_assert(std::is_same_v() % length(1)), length>); -static_assert((1m + km).count() == 1001); -static_assert((1m + 1km).count() == 1001); -static_assert((km - 1m).count() == 999); -static_assert((1km - 1m).count() == 999); -static_assert((2m * 2).count() == 4); -static_assert((3 * 3m).count() == 9); -static_assert((4m / 2).count() == 2); -static_assert(4m / 2m == 2); -static_assert(4km / 2000m == 2); -static_assert((7m % 2).count() == 1); -static_assert((7m % 2m).count() == 1); -static_assert((7km % 2000m).count() == 1000); +static_assert((1q_m + km).count() == 1001); +static_assert((1q_m + 1q_km).count() == 1001); +static_assert((km - 1q_m).count() == 999); +static_assert((1q_km - 1q_m).count() == 999); +static_assert((2q_m * 2).count() == 4); +static_assert((3 * 3q_m).count() == 9); +static_assert((4q_m / 2).count() == 2); +static_assert(4q_m / 2q_m == 2); +static_assert(4q_km / 2000q_m == 2); +static_assert((7q_m % 2).count() == 1); +static_assert((7q_m % 2q_m).count() == 1); +static_assert((7q_km % 2000q_m).count() == 1000); -static_assert((10km2 * 10km2) / 50km2 == 2km2); +static_assert((10q_km2 * 10q_km2) / 50q_km2 == 2q_km2); // comparators -static_assert(2m + 1m == 3m); -static_assert(!(2m + 2m == 3m)); -static_assert(2m + 2m != 3m); -static_assert(!(2m + 2m != 4m)); -static_assert(2m > 1m); -static_assert(!(1m > 1m)); -static_assert(1m < 2m); -static_assert(!(2m < 2m)); -static_assert(2m >= 1m); -static_assert(2m >= 2m); -static_assert(!(2m >= 3m)); -static_assert(1m <= 2m); -static_assert(2m <= 2m); -static_assert(!(3m <= 2m)); +static_assert(2q_m + 1q_m == 3q_m); +static_assert(!(2q_m + 2q_m == 3q_m)); +static_assert(2q_m + 2q_m != 3q_m); +static_assert(!(2q_m + 2q_m != 4q_m)); +static_assert(2q_m > 1q_m); +static_assert(!(1q_m > 1q_m)); +static_assert(1q_m < 2q_m); +static_assert(!(2q_m < 2q_m)); +static_assert(2q_m >= 1q_m); +static_assert(2q_m >= 2q_m); +static_assert(!(2q_m >= 3q_m)); +static_assert(1q_m <= 2q_m); +static_assert(2q_m <= 2q_m); +static_assert(!(3q_m <= 2q_m)); -static_assert(3m == 3.0m); -static_assert(3m != 3.14m); -static_assert(2m > 1.0m); -static_assert(1.0m < 2m); -static_assert(2.0m >= 1m); -static_assert(1m <= 2.0m); +static_assert(3q_m == 3.0q_m); +static_assert(3q_m != 3.14q_m); +static_assert(2q_m > 1.0q_m); +static_assert(1.0q_m < 2q_m); +static_assert(2.0q_m >= 1q_m); +static_assert(1q_m <= 2.0q_m); -static_assert(1000m == 1km); -static_assert(1001m != 1km); -static_assert(1001m > 1km); -static_assert(999m < 1km); -static_assert(1000m >= 1km); -static_assert(1000m <= 1km); +static_assert(1000q_m == 1q_km); +static_assert(1001q_m != 1q_km); +static_assert(1001q_m > 1q_km); +static_assert(999q_m < 1q_km); +static_assert(1000q_m >= 1q_km); +static_assert(1000q_m <= 1q_km); // is_quantity @@ -317,35 +317,35 @@ static_assert(std::is_same_v, lengt // quantity_cast -static_assert(std::is_same_v, metre>>(2km))::unit, metre>); +static_assert(std::is_same_v, metre>>(2q_km))::unit, metre>); -static_assert(quantity_cast>(2km).count() == 2000); -static_assert(quantity_cast>(2000m).count() == 2); -static_assert(quantity_cast>(1.23m).count() == 1); -static_assert(quantity_cast(2km).count() == 2000); -static_assert(quantity_cast(2000m).count() == 2); -static_assert(quantity_cast(1.23m).count() == 1); +static_assert(quantity_cast>(2q_km).count() == 2000); +static_assert(quantity_cast>(2000q_m).count() == 2); +static_assert(quantity_cast>(1.23q_m).count() == 1); +static_assert(quantity_cast(2q_km).count() == 2000); +static_assert(quantity_cast(2000q_m).count() == 2); +static_assert(quantity_cast(1.23q_m).count() == 1); // time -// static_assert(1s == 1m); // should not compile (different dimensions) -static_assert(1h == 3600s); +// static_assert(1q_s == 1q_m); // should not compile (different dimensions) +static_assert(1q_h == 3600q_s); // length -static_assert(1km == 1000m); -static_assert(1km + 1m == 1001m); -static_assert(10km / 5km == 2); -static_assert(10km / 2 == 5km); +static_assert(1q_km == 1000q_m); +static_assert(1q_km + 1q_m == 1001q_m); +static_assert(10q_km / 5q_km == 2); +static_assert(10q_km / 2 == 5q_km); // velocity -static_assert(10m / 5s == 2mps); -static_assert(10 / 5s * 1m == 2mps); -static_assert(1km / 1s == 1000mps); -static_assert(2kmph * 2h == 4km); -static_assert(2km / 2kmph == 1h); +static_assert(10q_m / 5q_s == 2q_mps); +static_assert(10 / 5q_s * 1q_m == 2q_mps); +static_assert(1q_km / 1q_s == 1000q_mps); +static_assert(2q_kmph * 2q_h == 4q_km); +static_assert(2q_km / 2q_kmph == 1q_h); -static_assert(std::is_same_v(2m)), decltype(4m2)>); +static_assert(std::is_same_v(2q_m)), decltype(4q_m2)>); } // namespace diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp index cbc03194..d2fcf10a 100644 --- a/test/unit_test/static/si_cgs_test.cpp +++ b/test/unit_test/static/si_cgs_test.cpp @@ -61,15 +61,15 @@ namespace si_test { using namespace units::si::literals; -static_assert(cgs::length(100) == 1m); -static_assert(cgs::mass(1'000) == 1kg); -static_assert(cgs::time(1) == 1s); -static_assert(cgs::velocity(100) == 1mps); -static_assert(cgs::acceleration(100) == 1mps2); -static_assert(cgs::force(100'000) == 1N); -static_assert(cgs::energy(10'000'000) == 1_J); -static_assert(cgs::power(10'000'000) == 1W); -static_assert(cgs::pressure(10) == 1Pa); +static_assert(cgs::length(100) == 1q_m); +static_assert(cgs::mass(1'000) == 1q_kg); +static_assert(cgs::time(1) == 1q_s); +static_assert(cgs::velocity(100) == 1q_mps); +static_assert(cgs::acceleration(100) == 1q_mps2); +static_assert(cgs::force(100'000) == 1q_N); +static_assert(cgs::energy(10'000'000) == 1q_J); +static_assert(cgs::power(10'000'000) == 1q_W); +static_assert(cgs::pressure(10) == 1q_Pa); } @@ -77,15 +77,15 @@ namespace cgs_test { using namespace units::cgs::literals; -static_assert(100cm == si::length(1)); -static_assert(1'000g == si::mass(1)); -static_assert(1s == si::time(1)); -static_assert(100cmps == si::velocity(1)); -static_assert(100Gal == si::acceleration(1)); -static_assert(100'000dyn == si::force(1)); -static_assert(10'000'000_erg == si::energy(1)); -static_assert(10'000'000_ergps == si::power(1)); -static_assert(10Ba == si::pressure(1)); +static_assert(100q_cm == si::length(1)); +static_assert(1'000q_g == si::mass(1)); +static_assert(1q_s == si::time(1)); +static_assert(100q_cmps == si::velocity(1)); +static_assert(100q_Gal == si::acceleration(1)); +static_assert(100'000q_dyn == si::force(1)); +static_assert(10'000'000q_erg == si::energy(1)); +static_assert(10'000'000q_ergps == si::power(1)); +static_assert(10q_Ba == si::pressure(1)); } @@ -94,15 +94,15 @@ namespace both_test { using namespace units::si::literals; using namespace units::cgs::literals; -// static_assert(100cm == 1m); // ambiguous -// static_assert(1'000g == 1kg); // ambiguous -static_assert(1s == 1s); -static_assert(100cmps == 1mps); -static_assert(100Gal == 1mps2); -static_assert(100'000dyn == 1N); -static_assert(10'000'000_erg == 1_J); -static_assert(10'000'000_ergps == 1W); -static_assert(10Ba == quantity_cast(1Pa)); +// static_assert(100q_cm == 1q_m); // ambiguous +// static_assert(1'000q_g == 1q_kg); // ambiguous +static_assert(1q_s == 1q_s); +static_assert(100q_cmps == 1q_mps); +static_assert(100q_Gal == 1q_mps2); +static_assert(100'000q_dyn == 1q_N); +static_assert(10'000'000q_erg == 1q_J); +static_assert(10'000'000q_ergps == 1q_W); +static_assert(10q_Ba == quantity_cast(1q_Pa)); } @@ -110,41 +110,41 @@ namespace cgs_test { // addition -// static_assert(100cm + si::length(1) == si::length(2)); // should not compile (different dimensions) -// static_assert(si::length(1) + 100cm == si::length(2)); // should not compile (different dimensions) -static_assert(quantity_cast>(100cm) + si::length(1) == si::length(2)); -static_assert(si::length(1) + quantity_cast>(100cm) == si::length(2)); -static_assert(100cm + quantity_cast>(si::length(1)) == 200cm); -static_assert(quantity_cast>(si::length(1)) + 100cm == 200cm); +// static_assert(100q_cm + si::length(1) == si::length(2)); // should not compile (different dimensions) +// static_assert(si::length(1) + 100q_cm == si::length(2)); // should not compile (different dimensions) +static_assert(quantity_cast>(100q_cm) + si::length(1) == si::length(2)); +static_assert(si::length(1) + quantity_cast>(100q_cm) == si::length(2)); +static_assert(100q_cm + quantity_cast>(si::length(1)) == 200q_cm); +static_assert(quantity_cast>(si::length(1)) + 100q_cm == 200q_cm); // substraction -// static_assert(500cm - si::length(1) == si::length(4)); // should not compile (different dimensions) -// static_assert(si::length(5) - 100cm == si::length(4)); // should not compile (different dimensions) -static_assert(quantity_cast>(500cm) - si::length(1) == si::length(4)); -static_assert(si::length(5) - quantity_cast>(100cm) == si::length(4)); -static_assert(500cm - quantity_cast>(si::length(1)) == 400cm); -static_assert(quantity_cast>(si::length(5)) - 100cm == 400cm); +// static_assert(500q_cm - si::length(1) == si::length(4)); // should not compile (different dimensions) +// static_assert(si::length(5) - 100q_cm == si::length(4)); // should not compile (different dimensions) +static_assert(quantity_cast>(500q_cm) - si::length(1) == si::length(4)); +static_assert(si::length(5) - quantity_cast>(100q_cm) == si::length(4)); +static_assert(500q_cm - quantity_cast>(si::length(1)) == 400q_cm); +static_assert(quantity_cast>(si::length(5)) - 100q_cm == 400q_cm); // multiplication -// static_assert(200cm * si::length(2) == si::area(4)); // should not compile (unknown dimension) +// static_assert(200q_cm * si::length(2) == si::area(4)); // should not compile (unknown dimension) -static_assert(quantity_cast(200cm) * si::length(2) == si::area(4)); -static_assert(200cm * quantity_cast(si::length(2)) == 40'000cm2); +static_assert(quantity_cast(200q_cm) * si::length(2) == si::area(4)); +static_assert(200q_cm * quantity_cast(si::length(2)) == 40'000q_cm2); // TODO Add support for quantity_cast on an unknown_dimension? -// static_assert(quantity_cast>(200cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast(200cm * si::length(2)) == si::area(4)); -// static_assert(quantity_cast>(200cm * si::length(2)) == 40'000sq_cm); -// static_assert(quantity_cast(200cm * si::length(2)) == 40'000sq_cm); +// static_assert(quantity_cast>(200q_cm * si::length(2)) == si::area(4)); +// static_assert(quantity_cast(200q_cm * si::length(2)) == si::area(4)); +// static_assert(quantity_cast>(200q_cm * si::length(2)) == 40'000q_sq_cm); +// static_assert(quantity_cast(200q_cm * si::length(2)) == 40'000q_sq_cm); // division -// static_assert(si::area(4) / 200cm == si::length(2)); // should not compile (unknown dimension) +// static_assert(si::area(4) / 200q_cm == si::length(2)); // should not compile (unknown dimension) -static_assert(si::area(4) / quantity_cast>(200cm) == si::length(2)); -static_assert(quantity_cast>(si::area(4)) / 200cm == 200cm); +static_assert(si::area(4) / quantity_cast>(200q_cm) == si::length(2)); +static_assert(quantity_cast>(si::area(4)) / 200q_cm == 200q_cm); } diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 80a02362..8a2ce4a6 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -51,16 +51,16 @@ using namespace units::si; // length -static_assert(1km == 1000m); -static_assert(1m == 100cm); -static_assert(1m == 10dm); -static_assert(1m == 1000mm); -static_assert(1hm == 100m); -static_assert(1au == 149'597'870'700m); -static_assert(1km + 1m == 1001m); -static_assert(10km / 5km == 2); -static_assert(100mm / 5cm == 2); -static_assert(10km / 2 == 5km); +static_assert(1q_km == 1000q_m); +static_assert(1q_m == 100q_cm); +static_assert(1q_m == 10q_dm); +static_assert(1q_m == 1000q_mm); +static_assert(1q_hm == 100q_m); +static_assert(1q_au == 149'597'870'700q_m); +static_assert(1q_km + 1q_m == 1001q_m); +static_assert(10q_km / 5q_km == 2); +static_assert(100q_mm / 5q_cm == 2); +static_assert(10q_km / 2 == 5q_km); static_assert(millimetre::symbol == "mm"); static_assert(centimetre::symbol == "cm"); @@ -69,21 +69,21 @@ static_assert(kilometre::symbol == "km"); // mass -static_assert(1kg == 1000g); -static_assert(1t == 1000kg); +static_assert(1q_kg == 1000q_g); +static_assert(1q_t == 1000q_kg); static_assert(kilogram::symbol == "kg"); // time -static_assert(1us == 1000ns); -static_assert(1ms == 1000us); -static_assert(1s == 1000ms); -static_assert(1min == 60s); -static_assert(1h == 60min); -static_assert(1h == 3600s); -static_assert(1_d == 24h); -static_assert(1_d == 86'400s); +static_assert(1q_us == 1000q_ns); +static_assert(1q_ms == 1000q_us); +static_assert(1q_s == 1000q_ms); +static_assert(1q_min == 60q_s); +static_assert(1q_h == 60q_min); +static_assert(1q_h == 3600q_s); +static_assert(1q_d == 24q_h); +static_assert(1q_d == 86'400q_s); static_assert(nanosecond::symbol == "ns"); static_assert(microsecond::symbol == "µs"); @@ -101,11 +101,11 @@ static_assert(millisecond::symbol == "ms"); // frequency -static_assert(1000mHz == 1Hz); -static_assert(1000Hz == 1kHz); -static_assert(1000kHz == 1MHz); -static_assert(1000MHz == 1GHz); -static_assert(1000GHz == 1THz); +static_assert(1000q_mHz == 1q_Hz); +static_assert(1000q_Hz == 1q_kHz); +static_assert(1000q_kHz == 1q_MHz); +static_assert(1000q_MHz == 1q_GHz); +static_assert(1000q_GHz == 1q_THz); static_assert(millihertz::symbol == "mHz"); static_assert(kilohertz::symbol == "kHz"); @@ -113,140 +113,140 @@ static_assert(megahertz::symbol == "MHz"); static_assert(gigahertz::symbol == "GHz"); static_assert(terahertz::symbol == "THz"); -static_assert(2 / 1s == 2Hz); -static_assert(120 / 1min == 2Hz); -static_assert(1000 / 1s == 1kHz); -static_assert(1 / 1ms == 1kHz); -static_assert(3.2GHz == 3'200'000'000Hz); -static_assert(10Hz * 1min == 600); -static_assert(2 / 1Hz == 2s); +static_assert(2 / 1q_s == 2q_Hz); +static_assert(120 / 1q_min == 2q_Hz); +static_assert(1000 / 1q_s == 1q_kHz); +static_assert(1 / 1q_ms == 1q_kHz); +static_assert(3.2q_GHz == 3'200'000'000q_Hz); +static_assert(10q_Hz * 1q_min == 600); +static_assert(2 / 1q_Hz == 2q_s); // force -static_assert(10kg * 10mps2 == 100N); -static_assert(100N / 1mps2 == 100kg); -static_assert(100N / 1kg == 100mps2); +static_assert(10q_kg * 10q_mps2 == 100q_N); +static_assert(100q_N / 1q_mps2 == 100q_kg); +static_assert(100q_N / 1q_kg == 100q_mps2); // pressure -static_assert(10N / 10m2 == 1Pa); -static_assert(10N / 1Pa == 10m2); -static_assert(1Pa * 10m2 == 10N); +static_assert(10q_N / 10q_m2 == 1q_Pa); +static_assert(10q_N / 1q_Pa == 10q_m2); +static_assert(1q_Pa * 10q_m2 == 10q_N); // energy -static_assert(1000mJ == 1_J); -static_assert(1000_J == 1kJ); -static_assert(1000kJ == 1MJ); -static_assert(1000MJ == 1GJ); +static_assert(1000q_mJ == 1q_J); +static_assert(1000q_J == 1q_kJ); +static_assert(1000q_kJ == 1q_MJ); +static_assert(1000q_MJ == 1q_GJ); static_assert(millijoule::symbol == "mJ"); static_assert(kilojoule::symbol == "kJ"); static_assert(megajoule::symbol == "MJ"); static_assert(gigajoule::symbol == "GJ"); -static_assert(10N * 10m == 100_J); -static_assert(100_J / 10m == 10N); -static_assert(100_J / 10N == 10m); -static_assert(10Pa * 10m3 == 100_J); -static_assert(100_J / 10Pa == 10m3); -static_assert(100_J / 10m3 == 10Pa); +static_assert(10q_N * 10q_m == 100q_J); +static_assert(100q_J / 10q_m == 10q_N); +static_assert(100q_J / 10q_N == 10q_m); +static_assert(10q_Pa * 10q_m3 == 100q_J); +static_assert(100q_J / 10q_Pa == 10q_m3); +static_assert(100q_J / 10q_m3 == 10q_Pa); // power -static_assert(1000mW == 1W); -static_assert(1000W == 1kW); -static_assert(1000kW == 1MW); -static_assert(1000MW == 1GW); +static_assert(1000q_mW == 1q_W); +static_assert(1000q_W == 1q_kW); +static_assert(1000q_kW == 1q_MW); +static_assert(1000q_MW == 1q_GW); static_assert(milliwatt::symbol == "mW"); static_assert(kilowatt::symbol == "kW"); static_assert(megawatt::symbol == "MW"); static_assert(gigawatt::symbol == "GW"); -static_assert(10_J / 10s == 1W); -static_assert(1W * 10s == 10_J); -static_assert(10_J / 1W == 10s); +static_assert(10q_J / 10q_s == 1q_W); +static_assert(1q_W * 10q_s == 10q_J); +static_assert(10q_J / 1q_W == 10q_s); // electric charge -static_assert(10A * 10s == 100C); -static_assert(100C / 10A == 10s); -static_assert(100C / 10s == 10A); +static_assert(10q_A * 10q_s == 100q_C); +static_assert(100q_C / 10q_A == 10q_s); +static_assert(100q_C / 10q_s == 10q_A); // voltage -static_assert(10W / 10A == 1V); -static_assert(10W / 1V == 10A); -static_assert(1V * 10A == 10W); -static_assert(10_J / 10C == 1V); -static_assert(10_J / 1V == 10C); -static_assert(10C * 1V == 10_J); +static_assert(10q_W / 10q_A == 1q_V); +static_assert(10q_W / 1q_V == 10q_A); +static_assert(1q_V * 10q_A == 10q_W); +static_assert(10q_J / 10q_C == 1q_V); +static_assert(10q_J / 1q_V == 10q_C); +static_assert(10q_C * 1q_V == 10q_J); // capacitance -static_assert(10C / 10V == 1F); -static_assert(10C / 1F == 10V); -static_assert(10V * 1F == 10C); +static_assert(10q_C / 10q_V == 1q_F); +static_assert(10q_C / 1q_F == 10q_V); +static_assert(10q_V * 1q_F == 10q_C); /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ // velocity -static_assert(std::is_same_v, metre_per_second>, std::int64_t>>); +static_assert(std::is_same_v, metre_per_second>, std::int64_t>>); -static_assert(10m / 5s == 2mps); -static_assert(10 / 5s * 1m == 2mps); -static_assert(1km / 1s == 1000mps); -// static_assert(1km / 1h == 1kmph); // should not compile -static_assert(1.0km / 1h == 1kmph); -static_assert(1000.0m / 3600.0s == 1kmph); +static_assert(10q_m / 5q_s == 2q_mps); +static_assert(10 / 5q_s * 1q_m == 2q_mps); +static_assert(1q_km / 1q_s == 1000q_mps); +// static_assert(1q_km / 1q_h == 1q_kmph); // should not compile +static_assert(1.0q_km / 1q_h == 1q_kmph); +static_assert(1000.0q_m / 3600.0q_s == 1q_kmph); -static_assert(2kmph * 2h == 4km); -// static_assert(2kmph * 15min == 500m); // should not compile -static_assert(2kmph * 15.0min == 500m); -static_assert(2.0kmph * 15min == 500m); +static_assert(2q_kmph * 2q_h == 4q_km); +// static_assert(2q_kmph * 15q_min == 500q_m); // should not compile +static_assert(2q_kmph * 15.0q_min == 500q_m); +static_assert(2.0q_kmph * 15q_min == 500q_m); -static_assert(2km / 2kmph == 1h); -// static_assert(2000m / 2kmph == 1h); // should not compile -static_assert(quantity_cast(2000m) / 2kmph == 1h); +static_assert(2q_km / 2q_kmph == 1q_h); +// static_assert(2000q_m / 2q_kmph == 1q_h); // should not compile +static_assert(quantity_cast(2000q_m) / 2q_kmph == 1q_h); static_assert(detail::unit_text() == "m/s"); static_assert(kilometre_per_hour::symbol == "km/h"); // acceleration -static_assert(10mps / 10s == 1mps2); -static_assert(10mps / 1mps2 == 10s); -static_assert(1mps2 * 10s == 10mps); +static_assert(10q_mps / 10q_s == 1q_mps2); +static_assert(10q_mps / 1q_mps2 == 10q_s); +static_assert(1q_mps2 * 10q_s == 10q_mps); static_assert(detail::unit_text() == "m/s²"); // area -static_assert(10m * 10m == 100m2); -static_assert(100m2 / 10m == 10m); -static_assert(10km * 10km == 100km2); -static_assert(1m2 == 10'000cm2); -static_assert(1ha == 10'000m2); +static_assert(10q_m * 10q_m == 100q_m2); +static_assert(100q_m2 / 10q_m == 10q_m); +static_assert(10q_km * 10q_km == 100q_km2); +static_assert(1q_m2 == 10'000q_cm2); +static_assert(1q_ha == 10'000q_m2); static_assert(detail::unit_text() == "m²"); // volume -static_assert(1m * 1m * 1m == 1m3); -static_assert(10m2 * 10m == 100m3); -static_assert(10km * 10km * 10km == 1000km3); -static_assert(1m3 == 1'000'000cm3); -static_assert(1dm * 1dm * 1dm == 1_l); -static_assert(1000_l == 1m3); +static_assert(1q_m * 1q_m * 1q_m == 1q_m3); +static_assert(10q_m2 * 10q_m == 100q_m3); +static_assert(10q_km * 10q_km * 10q_km == 1000q_km3); +static_assert(1q_m3 == 1'000'000q_cm3); +static_assert(1q_dm * 1q_dm * 1q_dm == 1q_l); +static_assert(1000q_l == 1q_m3); static_assert(detail::unit_text() == "m³"); /* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */ -static_assert(10N / 2m == 5Npm); -static_assert(10N / 5Npm == 2m); -static_assert(2m * 5Npm == 10N); +static_assert(10q_N / 2q_m == 5q_Npm); +static_assert(10q_N / 5q_Npm == 2q_m); +static_assert(2q_m * 5q_Npm == 10q_N); static_assert(detail::unit_text() == "N/m"); diff --git a/test/unit_test/static/us_test.cpp b/test/unit_test/static/us_test.cpp index b03a90e3..f4069973 100644 --- a/test/unit_test/static/us_test.cpp +++ b/test/unit_test/static/us_test.cpp @@ -42,19 +42,19 @@ using namespace units::international; // length -static_assert(1yd == 0.9144m); -static_assert(1yd == 3ft); -static_assert(1ft == 12in); -static_assert(1mi == 1760yd); +static_assert(1q_yd == 0.9144q_m); +static_assert(1q_yd == 3q_ft); +static_assert(1q_ft == 12q_in); +static_assert(1q_mi == 1760q_yd); -static_assert(5in + 8cm == 207mm); +static_assert(5q_in + 8q_cm == 207q_mm); /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ // velocity -static_assert(10.0mi / 2h == 5mph); +static_assert(10.0q_mi / 2q_h == 5q_mph); static_assert(mile_per_hour::symbol == "mi/h"); diff --git a/test_package/test_package.cpp b/test_package/test_package.cpp index a8a30cd9..901168ff 100644 --- a/test_package/test_package.cpp +++ b/test_package/test_package.cpp @@ -31,5 +31,5 @@ constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO int main() { using namespace units::si::literals; - std::cout << "Average speed = " << avg_speed(240.km, 2h) << '\n'; + std::cout << "Average speed = " << avg_speed(240.q_km, 2q_h) << '\n'; }