From e660278fa893132cc0782e3fccc369896c00dabd Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 19 Apr 2022 18:49:48 +0200 Subject: [PATCH] feat: `nautical_mile_per_hour` and `knot` added to `si::international` system Relates to #357 --- .../units/isq/si/international/speed.h | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/systems/si-international/include/units/isq/si/international/speed.h b/src/systems/si-international/include/units/isq/si/international/speed.h index 3ce51418..df074b84 100644 --- a/src/systems/si-international/include/units/isq/si/international/speed.h +++ b/src/systems/si-international/include/units/isq/si/international/speed.h @@ -35,6 +35,9 @@ namespace units::isq::si::international { struct mile_per_hour : derived_unit {}; +struct nautical_mile_per_hour : + derived_unit {}; +struct knot : alias_unit {}; #ifndef UNITS_NO_LITERALS @@ -48,10 +51,42 @@ constexpr auto operator"" _q_mi_per_h(unsigned long long l) } constexpr auto operator"" _q_mi_per_h(long double l) { return si::speed(l); } +// nmi/h +constexpr auto operator"" _q_nmi_per_h(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::speed(static_cast(l)); +} +constexpr auto operator"" _q_nmi_per_h(long double l) { return si::speed(l); } + +// kn +constexpr auto operator"" _q_kn(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::speed(static_cast(l)); +} +constexpr auto operator"" _q_kn(long double l) { return si::speed(l); } + } // namespace literals #endif // UNITS_NO_LITERALS +#ifndef UNITS_NO_REFERENCES + +namespace speed_references { + +inline constexpr auto kn = reference{}; + +} // namespace speed_references + +namespace references { + +using namespace speed_references; + +} // namespace references + +#endif // UNITS_NO_REFERENCES + } // namespace units::isq::si::international #ifndef UNITS_NO_ALIASES @@ -61,6 +96,12 @@ namespace units::aliases::isq::si::international::inline speed { template using mi_per_h = units::isq::si::speed; +template +using nmi_per_h = units::isq::si::speed; + +template +using kn = units::isq::si::speed; + } // namespace units::aliases::isq::si::international::inline speed #endif // UNITS_NO_ALIASES