diff --git a/example/avg_speed.cpp b/example/avg_speed.cpp index 33631501..fd46a74b 100644 --- a/example/avg_speed.cpp +++ b/example/avg_speed.cpp @@ -61,8 +61,8 @@ void example() { // SI (int) { - constexpr auto distance = 220 * isq::length[km]; - constexpr auto duration = 2 * isq::time[h]; + constexpr auto distance = isq::length(220, km); + constexpr auto duration = isq::time(2, h); std::cout << "SI units with 'int' as representation\n"; @@ -73,8 +73,8 @@ void example() // SI (double) { - constexpr auto distance = 220. * isq::length[km]; - constexpr auto duration = 2. * isq::time[h]; + constexpr auto distance = isq::length(220., km); + constexpr auto duration = isq::time(2., h); std::cout << "\nSI units with 'double' as representation\n"; @@ -89,8 +89,8 @@ void example() { using namespace units::si::international::unit_symbols; - constexpr auto distance = 140 * isq::length[mi]; - constexpr auto duration = 2 * isq::time[h]; + constexpr auto distance = isq::length(140, mi); + constexpr auto duration = isq::time(2, h); std::cout << "\nUS Customary Units with 'int' as representation\n"; @@ -104,8 +104,8 @@ void example() // Customary Units (double) { using namespace units::si::international::unit_symbols; - constexpr auto distance = 140. * isq::length[mi]; - constexpr auto duration = 2. * isq::time[h]; + constexpr auto distance = isq::length(140., mi); + constexpr auto duration = isq::time(2., h); std::cout << "\nUS Customary Units with 'double' as representation\n"; @@ -121,8 +121,8 @@ void example() // CGS (int) { - constexpr auto distance = 22'000'000 * isq::length[si::cgs::centimetre]; - constexpr auto duration = 7200 * isq::time[si::cgs::second]; + constexpr auto distance = isq::length(22'000'000, si::cgs::centimetre); + constexpr auto duration = isq::time(7200, si::cgs::second); std::cout << "\nCGS units with 'int' as representation\n"; @@ -135,8 +135,8 @@ void example() // CGS (double) { - constexpr auto distance = 22'000'000. * isq::length[si::cgs::centimetre]; - constexpr auto duration = 7200. * isq::time[si::cgs::second]; + constexpr auto distance = isq::length(22'000'000., si::cgs::centimetre); + constexpr auto duration = isq::time(7200., si::cgs::second); std::cout << "\nCGS units with 'double' as representation\n"; diff --git a/example/box_example.cpp b/example/box_example.cpp index 0aa335cd..52779218 100644 --- a/example/box_example.cpp +++ b/example/box_example.cpp @@ -40,8 +40,8 @@ namespace { using namespace units; using namespace units::si::unit_symbols; -inline constexpr auto g = 1 * si::standard_gravity; -inline constexpr auto air_density = 1.225 * isq::mass_density[kg / m3]; +inline constexpr auto g = si::standard_gravity(1); +inline constexpr auto air_density = isq::mass_density(1.225, kg / m3); class Box { quantity base_; @@ -87,12 +87,12 @@ int main() constexpr auto mm = isq::length[unit_symbols::mm]; // helper reference object - const auto height = (200.0 * mm)[metre]; - auto box = Box(1000.0 * mm, 500.0 * mm, height); - box.set_contents_density(1000.0 * isq::mass_density[kg / m3]); + const auto height = mm(200.0)[metre]; + auto box = Box(mm(1000.0), mm(500.0), height); + box.set_contents_density(isq::mass_density(1000.0, kg / m3)); - const auto fill_time = 200.0 * isq::time[s]; // time since starting fill - const auto measured_mass = 20.0 * isq::mass[kg]; // measured mass at fill_time + const auto fill_time = isq::time(200.0, s); // time since starting fill + const auto measured_mass = isq::mass(20.0, kg); // measured mass at fill_time const auto fill_level = box.fill_level(measured_mass); const auto spare_capacity = box.spare_capacity(measured_mass); const auto filled_weight = box.filled_weight(); diff --git a/example/capacitor_time_curve.cpp b/example/capacitor_time_curve.cpp index c07a4e89..f453eb66 100644 --- a/example/capacitor_time_curve.cpp +++ b/example/capacitor_time_curve.cpp @@ -35,22 +35,22 @@ int main() std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); std::cout.precision(3); - constexpr auto C = 0.47 * isq::capacitance[uF]; - constexpr auto V0 = 5.0 * isq::voltage[V]; - constexpr auto R = 4.7 * isq::resistance[si::kilo]; + constexpr auto C = isq::capacitance(0.47, uF); + constexpr auto V0 = isq::voltage(5.0, V); + constexpr auto R = isq::resistance(4.7, si::kilo); - for (auto t = 0 * isq::time[ms]; t <= 50 * isq::time[ms]; ++t) { + for (auto t = isq::time(0, ms); t <= isq::time(50, ms); ++t) { const weak_quantity_of auto Vt = V0 * units::exp(-t / (R * C)); std::cout << "at " << t << " voltage is "; - if (Vt >= 1 * isq::voltage[V]) + if (Vt >= isq::voltage(1, V)) std::cout << Vt[V]; - else if (Vt >= 1 * isq::voltage[mV]) + else if (Vt >= isq::voltage(1, mV)) std::cout << Vt[mV]; - else if (Vt >= 1 * isq::voltage[uV]) + else if (Vt >= isq::voltage(1, uV)) std::cout << Vt[uV]; - else if (Vt >= 1 * isq::voltage[nV]) + else if (Vt >= isq::voltage(1, nV)) std::cout << Vt[nV]; else std::cout << Vt[pV]; diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 16e3ee84..263f896a 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -43,7 +43,7 @@ int main() std::cout << "conversion factor in mp-units...\n\n"; - constexpr auto lengthA = 2.0 * isq::length[si::metre]; + constexpr auto lengthA = isq::length(2.0, si::metre); constexpr auto lengthB = lengthA[si::milli]; std::cout << STD_FMT::format("lengthA( {} ) and lengthB( {} )\n", lengthA, lengthB) diff --git a/example/hello_units.cpp b/example/hello_units.cpp index f41d2e21..1198ca23 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -40,9 +40,9 @@ int main() using namespace units::si::unit_symbols; using namespace units::si::international::unit_symbols; - constexpr auto v1 = 110 * isq::speed[km / h]; - constexpr auto v2 = 70. * isq::speed[mph]; - constexpr auto v3 = avg_speed(220 * isq::distance[km], 2 * isq::duration[h]); + constexpr auto v1 = isq::speed(110, km / h); + constexpr auto v2 = isq::speed(70., mph); + constexpr auto v3 = avg_speed(isq::distance(220, km), isq::duration(2, h)); constexpr auto v4 = avg_speed(quantity{140}, quantity{2}); constexpr auto v5 = quantity_cast>(v3); constexpr auto v6 = quantity_cast(v4); diff --git a/example/measurement.cpp b/example/measurement.cpp index 6d43de1f..281e40c6 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -131,13 +131,13 @@ void example() using namespace units; using namespace units::si::unit_symbols; - const auto a = measurement{9.8, 0.1} * isq::acceleration[m / s2]; - const auto t = measurement{1.2, 0.1} * isq::time[s]; + const auto a = isq::acceleration(measurement{9.8, 0.1}, m / s2); + const auto t = isq::time(measurement{1.2, 0.1}, s); const weak_quantity_of auto v = a * t; std::cout << a << " * " << t << " = " << v << " = " << v[km / h] << '\n'; - const auto length = measurement{123., 1.} * isq::length[si::metre]; + const auto length = isq::length(measurement{123., 1.}, si::metre); std::cout << "10 * " << length << " = " << 10 * length << '\n'; } diff --git a/example/si_constants.cpp b/example/si_constants.cpp index 966b23cd..45647710 100644 --- a/example/si_constants.cpp +++ b/example/si_constants.cpp @@ -36,19 +36,19 @@ int main() std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n"; std::cout << STD_FMT::format("- hyperfine transition frequency of Cs: {} = {:%.0Q %q}\n", - 1. * si2019::hyperfine_structure_transition_frequency_of_cs, - (1. * si2019::hyperfine_structure_transition_frequency_of_cs)[Hz]); + si2019::hyperfine_structure_transition_frequency_of_cs(1.), + si2019::hyperfine_structure_transition_frequency_of_cs(1.)[Hz]); std::cout << STD_FMT::format("- speed of light in vacuum: {} = {:%.0Q %q}\n", - 1. * si2019::speed_of_light_in_vacuum, (1. * si2019::speed_of_light_in_vacuum)[m / s]); + si2019::speed_of_light_in_vacuum(1.), si2019::speed_of_light_in_vacuum(1.)[m / s]); std::cout << STD_FMT::format("- Planck constant: {} = {:%.8eQ %q}\n", - 1. * si2019::planck_constant, (1. * si2019::planck_constant)[J * s]); + si2019::planck_constant(1.), si2019::planck_constant(1.)[J * s]); std::cout << STD_FMT::format("- elementary charge: {} = {:%.9eQ %q}\n", - 1. * si2019::elementary_charge, (1. * si2019::elementary_charge)[C]); + si2019::elementary_charge(1.), si2019::elementary_charge(1.)[C]); std::cout << STD_FMT::format("- Boltzmann constant: {} = {:%.6eQ %q}\n", - 1. * si2019::boltzmann_constant, (1. * si2019::boltzmann_constant)[J / K]); + si2019::boltzmann_constant(1.), si2019::boltzmann_constant(1.)[J / K]); std::cout << STD_FMT::format("- Avogadro constant: {} = {:%.8eQ %q}\n", - 1. * si2019::avogadro_constant, (1. * si2019::avogadro_constant)[1 / mol]); + si2019::avogadro_constant(1.), si2019::avogadro_constant(1.)[1 / mol]); // TODO uncomment the below when ISQ is done - // std::cout << STD_FMT::format("- luminous efficacy: {} = {}\n", 1. * si2019::luminous_efficacy, - // (1. * si2019::luminous_efficacy)[lm / W]); + // std::cout << STD_FMT::format("- luminous efficacy: {} = {}\n", si2019::luminous_efficacy(1.), + // si2019::luminous_efficacy(1.)[lm / W]); } diff --git a/example/total_energy.cpp b/example/total_energy.cpp index 8fec060c..2d4741c0 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -49,9 +49,9 @@ void si_example() using namespace units::si::unit_symbols; constexpr auto GeV = si::giga; - constexpr quantity_of auto c = 1. * si::si2019::speed_of_light_in_vacuum; - const weak_quantity_of auto p1 = 4. * isq::mechanical_energy[GeV] / c; - const weak_quantity_of auto m1 = 3. * isq::mechanical_energy[GeV] / pow<2>(c); + constexpr quantity_of auto c = si::si2019::speed_of_light_in_vacuum(1.); + const weak_quantity_of auto p1 = isq::mechanical_energy(4., GeV) / c; + const weak_quantity_of auto m1 = isq::mechanical_energy(3., GeV) / pow<2>(c); const auto E = total_energy(p1, m1, c); std::cout << "\n*** SI units (c = " << c << " = " << c[si::metre / s] << ") ***\n";