From 2a7f2efa15dc27d5f905eac04ed069a4228339bc Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 26 Dec 2019 10:20:30 +0100 Subject: [PATCH] hectometre and hectare added --- src/include/units/physical/si/area.h | 6 ++++++ src/include/units/physical/si/length.h | 5 +++++ test/unit_test/static/si_test.cpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index fcfd83a8..c62a4d6a 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -35,6 +35,8 @@ struct square_millimetre : deduced_unit struct square_centimetre : deduced_unit {}; struct square_kilometre : deduced_unit {}; +struct hectare : deduced_unit {}; + template using area = quantity; @@ -56,6 +58,10 @@ constexpr auto operator"" sq_cm(long double l) { return area(l); } constexpr auto operator"" sq_km(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); } + } // namespace literals } // namespace units::si diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index 8dc939bf..5830323f 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -32,6 +32,7 @@ struct metre : named_unit {}; struct millimetre : prefixed_unit {}; struct centimetre : prefixed_unit {}; struct decimetre : prefixed_unit {}; +struct hectometre : prefixed_unit {}; struct kilometre : prefixed_unit {}; struct astronomical_unit : named_scaled_unit, metre> {}; @@ -59,6 +60,10 @@ constexpr auto operator"" cm(long double l) { return length(l); } constexpr auto operator"" 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); } + // km constexpr auto operator"" km(unsigned long long l) { return length(l); } constexpr auto operator"" km(long double l) { return length(l); } diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 840a6778..42ae4287 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -55,6 +55,7 @@ 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); @@ -225,6 +226,7 @@ static_assert(10m * 10m == 100sq_m); static_assert(100sq_m / 10m == 10m); static_assert(10km * 10km == 100sq_km); static_assert(1sq_m == 10'000sq_cm); +static_assert(1ha == 10'000sq_m); static_assert(detail::unit_text() == "m²");