diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 5bfbc860..bc838b30 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -21,36 +21,32 @@ // SOFTWARE. #include -#include -#include // IWYU pragma: keep -#include -#include // IWYU pragma: keep -#include +#include #include +#include +#include +#include #include -using namespace units::isq; +using namespace units; -constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } +constexpr quantity_of auto avg_speed(quantity_of auto d, quantity_of auto t) +{ + return quantity_cast(d / t); +} int main() { - using namespace units::isq::si::literals; - using namespace units::isq::si::references; - using namespace units::aliases::isq::si::international; + using namespace units::si::unit_symbols; + using namespace units::si::international::unit_symbols; - constexpr Speed auto v1 = 110 * (km / h); - constexpr Speed auto v2 = mi_per_h<>(70.); - constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h); - constexpr Speed auto v4 = avg_speed(si::length(140), si::time(2)); -#if UNITS_DOWNCAST_MODE == 0 - constexpr Speed auto v5 = quantity_cast>(v3); - constexpr Speed auto v6 = quantity_cast(v4); -#else - constexpr Speed auto v5 = quantity_cast>(v3); - constexpr Speed auto v6 = quantity_cast(v4); -#endif - constexpr Speed auto v7 = quantity_cast(v6); + constexpr auto v1 = 110 * isq::speed[km / h]; + constexpr auto v2 = 70. * isq::speed[mph]; + constexpr auto v3 = avg_speed(220 * isq::length[km], 2 * isq::time[h]); + constexpr auto v4 = avg_speed(quantity{140}, quantity{2}); + constexpr auto v5 = quantity_cast>(v3); + constexpr auto v6 = quantity_cast(v4); + constexpr auto v7 = quantity_cast(v6); std::cout << v1 << '\n'; // 110 km/h std::cout << v2 << '\n'; // 70 mi/h