From fe6a5da3f44adf35d03c296d21d4f21f4a453f73 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 16 Oct 2019 17:03:24 +0200 Subject: [PATCH] More units added for energy and power --- src/include/units/dimensions/energy.h | 22 +++++++++++++++++++++- src/include/units/dimensions/power.h | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/include/units/dimensions/energy.h b/src/include/units/dimensions/energy.h index 912a5d0d..68245abf 100644 --- a/src/include/units/dimensions/energy.h +++ b/src/include/units/dimensions/energy.h @@ -27,13 +27,17 @@ #include namespace units { - + struct energy : derived_dimension, exp> {}; template concept Energy = QuantityOf; struct joule : derived_unit {}; + struct millijoule : derived_unit> {}; + struct kilojoule : derived_unit> {}; + struct megajoule : derived_unit> {}; + struct gigajoule : derived_unit> {}; inline namespace literals { @@ -41,6 +45,22 @@ namespace units { constexpr auto operator""_J(unsigned long long l) { return quantity(l); } constexpr auto operator""_J(long double l) { return quantity(l); } + // mJ + constexpr auto operator""mJ(unsigned long long l) { return quantity(l); } + constexpr auto operator""mJ(long double l) { return quantity(l); } + + // kJ + constexpr auto operator""kJ(unsigned long long l) { return quantity(l); } + constexpr auto operator""kJ(long double l) { return quantity(l); } + + // MJ + constexpr auto operator""MJ(unsigned long long l) { return quantity(l); } + constexpr auto operator""MJ(long double l) { return quantity(l); } + + // GJ + constexpr auto operator""GJ(unsigned long long l) { return quantity(l); } + constexpr auto operator""GJ(long double l) { return quantity(l); } + } // namespace literals } // namespace units diff --git a/src/include/units/dimensions/power.h b/src/include/units/dimensions/power.h index ad76a4fa..0f09ec3f 100644 --- a/src/include/units/dimensions/power.h +++ b/src/include/units/dimensions/power.h @@ -33,6 +33,10 @@ namespace units { concept Power = QuantityOf; struct watt : derived_unit {}; + struct milliwatt : derived_unit> {}; + struct kilowatt : derived_unit> {}; + struct megawatt : derived_unit> {}; + struct gigawatt : derived_unit> {}; inline namespace literals { @@ -40,6 +44,22 @@ namespace units { constexpr auto operator""W(unsigned long long l) { return quantity(l); } constexpr auto operator""_W(long double l) { return quantity(l); } + // mW + constexpr auto operator""mW(unsigned long long l) { return quantity(l); } + constexpr auto operator""mW(long double l) { return quantity(l); } + + // kW + constexpr auto operator""kW(unsigned long long l) { return quantity(l); } + constexpr auto operator""kW(long double l) { return quantity(l); } + + // MW + constexpr auto operator""MW(unsigned long long l) { return quantity(l); } + constexpr auto operator""MW(long double l) { return quantity(l); } + + // GW + constexpr auto operator""GW(unsigned long long l) { return quantity(l); } + constexpr auto operator""GW(long double l) { return quantity(l); } + } // namespace literals } // namespace units