mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 20:04:27 +02:00
More units added for energy and power
This commit is contained in:
@@ -34,6 +34,10 @@ namespace units {
|
||||
concept Energy = QuantityOf<T, energy>;
|
||||
|
||||
struct joule : derived_unit<joule, decltype("J"_fs), energy, kilogram, metre, second> {};
|
||||
struct millijoule : derived_unit<millijoule, decltype("mJ"_fs), milli<joule>> {};
|
||||
struct kilojoule : derived_unit<kilojoule, decltype("kJ"_fs), kilo<joule>> {};
|
||||
struct megajoule : derived_unit<megajoule, decltype("MJ"_fs), mega<joule>> {};
|
||||
struct gigajoule : derived_unit<gigajoule, decltype("GJ"_fs), giga<joule>> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -41,6 +45,22 @@ namespace units {
|
||||
constexpr auto operator""_J(unsigned long long l) { return quantity<joule, std::int64_t>(l); }
|
||||
constexpr auto operator""_J(long double l) { return quantity<joule, long double>(l); }
|
||||
|
||||
// mJ
|
||||
constexpr auto operator""mJ(unsigned long long l) { return quantity<millijoule, std::int64_t>(l); }
|
||||
constexpr auto operator""mJ(long double l) { return quantity<millijoule, long double>(l); }
|
||||
|
||||
// kJ
|
||||
constexpr auto operator""kJ(unsigned long long l) { return quantity<kilojoule, std::int64_t>(l); }
|
||||
constexpr auto operator""kJ(long double l) { return quantity<kilojoule, long double>(l); }
|
||||
|
||||
// MJ
|
||||
constexpr auto operator""MJ(unsigned long long l) { return quantity<megajoule, std::int64_t>(l); }
|
||||
constexpr auto operator""MJ(long double l) { return quantity<megajoule, long double>(l); }
|
||||
|
||||
// GJ
|
||||
constexpr auto operator""GJ(unsigned long long l) { return quantity<gigajoule, std::int64_t>(l); }
|
||||
constexpr auto operator""GJ(long double l) { return quantity<gigajoule, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
|
@@ -33,6 +33,10 @@ namespace units {
|
||||
concept Power = QuantityOf<T, power>;
|
||||
|
||||
struct watt : derived_unit<watt, decltype("W"_fs), power, kilogram, metre, second> {};
|
||||
struct milliwatt : derived_unit<milliwatt, decltype("mW"_fs), milli<watt>> {};
|
||||
struct kilowatt : derived_unit<kilowatt, decltype("kW"_fs), kilo<watt>> {};
|
||||
struct megawatt : derived_unit<megawatt, decltype("MW"_fs), mega<watt>> {};
|
||||
struct gigawatt : derived_unit<gigawatt, decltype("GW"_fs), giga<watt>> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -40,6 +44,22 @@ namespace units {
|
||||
constexpr auto operator""W(unsigned long long l) { return quantity<watt, std::int64_t>(l); }
|
||||
constexpr auto operator""_W(long double l) { return quantity<watt, long double>(l); }
|
||||
|
||||
// mW
|
||||
constexpr auto operator""mW(unsigned long long l) { return quantity<milliwatt, std::int64_t>(l); }
|
||||
constexpr auto operator""mW(long double l) { return quantity<milliwatt, long double>(l); }
|
||||
|
||||
// kW
|
||||
constexpr auto operator""kW(unsigned long long l) { return quantity<kilowatt, std::int64_t>(l); }
|
||||
constexpr auto operator""kW(long double l) { return quantity<kilowatt, long double>(l); }
|
||||
|
||||
// MW
|
||||
constexpr auto operator""MW(unsigned long long l) { return quantity<megawatt, std::int64_t>(l); }
|
||||
constexpr auto operator""MW(long double l) { return quantity<megawatt, long double>(l); }
|
||||
|
||||
// GW
|
||||
constexpr auto operator""GW(unsigned long long l) { return quantity<gigawatt, std::int64_t>(l); }
|
||||
constexpr auto operator""GW(long double l) { return quantity<gigawatt, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
|
Reference in New Issue
Block a user