Short name added to derived unit definition

This commit is contained in:
Mateusz Pusz committed 2019-10-15 11:32:59 +02:00
1 parent 2bcc5fa4e5
commit b889c81cb9
24 files changed
+186 -78

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ namespace units {
template<typename T>
concept Acceleration = QuantityOf<T, acceleration>;
struct metre_per_second_sq : derived_unit<metre_per_second_sq, acceleration, metre, second> {};
struct metre_per_second_sq : derived_unit<metre_per_second_sq, decltype("m/s^2"_fs), acceleration, metre, second> {};
inline namespace literals {
+9 -5
View File
@@ -31,11 +31,11 @@ namespace units {
template<typename T>
concept Area = QuantityOf<T, area>;
struct square_millimetre : derived_unit<square_millimetre, area, millimetre> {};
struct square_centimetre : derived_unit<square_centimetre, area, centimetre> {};
struct square_metre : derived_unit<square_metre, area, metre> {};
struct square_kilometre : derived_unit<square_kilometre, area, kilometre> {};
struct square_foot : derived_unit<square_foot, area, foot> {};
struct square_millimetre : derived_unit<square_millimetre, decltype("mm^2"_fs), area, millimetre> {};
struct square_centimetre : derived_unit<square_centimetre, decltype("cm^2"_fs), area, centimetre> {};
struct square_metre : derived_unit<square_metre, decltype("m^2"_fs), area, metre> {};
struct square_kilometre : derived_unit<square_kilometre, decltype("km^2"_fs), area, kilometre> {};
struct square_foot : derived_unit<square_foot, decltype("ft^2"_fs), area, foot> {};
inline namespace literals {
@@ -55,6 +55,10 @@ namespace units {
constexpr auto operator""sq_km(unsigned long long l) { return quantity<square_kilometre, std::int64_t>(l); }
constexpr auto operator""sq_km(long double l) { return quantity<square_kilometre, long double>(l); }
// sq_ft
constexpr auto operator""sq_ft(unsigned long long l) { return quantity<square_foot, std::int64_t>(l); }
constexpr auto operator""sq_ft(long double l) { return quantity<square_foot, long double>(l); }
} // namespace literals
} // namespace units
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Capacitance = QuantityOf<T, capacitance>;
struct farad : derived_unit<farad, capacitance, kilogram, metre, second, ampere> {};
struct farad : derived_unit<farad, decltype("F"_fs), capacitance, kilogram, metre, second, ampere> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Current = QuantityOf<T, current>;
struct ampere : derived_unit<ampere, current> {};
struct ampere : derived_unit<ampere, decltype("A"_fs), current> {};
inline namespace literals {
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept ElectricCharge = QuantityOf<T, electric_charge>;
struct coulomb : derived_unit<coulomb, electric_charge, second, ampere> {};
struct coulomb : derived_unit<coulomb, decltype("C"_fs), electric_charge, second, ampere> {};
inline namespace literals {
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Energy = QuantityOf<T, energy>;
struct joule : derived_unit<joule, energy, kilogram, metre, second> {};
struct joule : derived_unit<joule, decltype("J"_fs), energy, kilogram, metre, second> {};
inline namespace literals {
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Force = QuantityOf<T, force>;
struct newton : derived_unit<newton, force, kilogram, metre, second> {};
struct newton : derived_unit<newton, decltype("N"_fs), force, kilogram, metre, second> {};
inline namespace literals {
+10 -10
View File
@@ -32,23 +32,23 @@ namespace units {
template<typename T>
concept Frequency = QuantityOf<T, frequency>;
struct hertz : derived_unit<hertz, frequency, second> {};
struct millihertz : derived_unit<millihertz, milli<hertz>> {};
struct kilohertz : derived_unit<kilohertz, kilo<hertz>> {};
struct megahertz : derived_unit<megahertz, mega<hertz>> {};
struct gigahertz : derived_unit<gigahertz, giga<hertz>> {};
struct terahertz : derived_unit<terahertz, tera<hertz>> {};
struct hertz : derived_unit<hertz, decltype("Hz"_fs), frequency, second> {};
struct millihertz : derived_unit<millihertz, decltype("mHz"_fs), milli<hertz>> {};
struct kilohertz : derived_unit<kilohertz, decltype("kHz"_fs), kilo<hertz>> {};
struct megahertz : derived_unit<megahertz, decltype("MHz"_fs), mega<hertz>> {};
struct gigahertz : derived_unit<gigahertz, decltype("GHz"_fs), giga<hertz>> {};
struct terahertz : derived_unit<terahertz, decltype("THz"_fs), tera<hertz>> {};
inline namespace literals {
// mHz
constexpr auto operator""mHz(unsigned long long l) { return quantity<millihertz, std::int64_t>(l); }
constexpr auto operator""mHz(long double l) { return quantity<millihertz, long double>(l); }
// Hz
constexpr auto operator""Hz(unsigned long long l) { return quantity<hertz, std::int64_t>(l); }
constexpr auto operator""Hz(long double l) { return quantity<hertz, long double>(l); }
// mHz
constexpr auto operator""mHz(unsigned long long l) { return quantity<millihertz, std::int64_t>(l); }
constexpr auto operator""mHz(long double l) { return quantity<millihertz, long double>(l); }
// kHz
constexpr auto operator""kHz(unsigned long long l) { return quantity<kilohertz, std::int64_t>(l); }
constexpr auto operator""kHz(long double l) { return quantity<kilohertz, long double>(l); }
+12 -12
View File
@@ -33,13 +33,17 @@ namespace units {
concept Length = QuantityOf<T, length>;
// SI units
struct metre : derived_unit<metre, length> {};
struct millimetre : derived_unit<millimetre, milli<metre>> {};
struct centimetre : derived_unit<centimetre, centi<metre>> {};
struct kilometre : derived_unit<kilometre, kilo<metre>> {};
struct metre : derived_unit<metre, decltype("m"_fs), length> {};
struct millimetre : derived_unit<millimetre, decltype("mm"_fs), milli<metre>> {};
struct centimetre : derived_unit<centimetre, decltype("cm"_fs), centi<metre>> {};
struct kilometre : derived_unit<kilometre, decltype("km"_fs), kilo<metre>> {};
inline namespace literals {
// m
constexpr auto operator""m(unsigned long long l) { return quantity<metre, std::int64_t>(l); }
constexpr auto operator""m(long double l) { return quantity<metre, long double>(l); }
// mm
constexpr auto operator""mm(unsigned long long l) { return quantity<millimetre, std::int64_t>(l); }
constexpr auto operator""mm(long double l) { return quantity<millimetre, long double>(l); }
@@ -48,10 +52,6 @@ namespace units {
constexpr auto operator""cm(unsigned long long l) { return quantity<centimetre, std::int64_t>(l); }
constexpr auto operator""cm(long double l) { return quantity<centimetre, long double>(l); }
// m
constexpr auto operator""m(unsigned long long l) { return quantity<metre, std::int64_t>(l); }
constexpr auto operator""m(long double l) { return quantity<metre, long double>(l); }
// km
constexpr auto operator""km(unsigned long long l) { return quantity<kilometre, std::int64_t>(l); }
constexpr auto operator""km(long double l) { return quantity<kilometre, long double>(l); }
@@ -59,10 +59,10 @@ namespace units {
} // namespace literals
// US customary units
struct yard : derived_unit<yard, length, ratio<9'144, 10'000>> {};
struct foot : derived_unit<foot, length, ratio_multiply<ratio<1, 3>, yard::ratio>> {};
struct inch : derived_unit<inch, length, ratio_multiply<ratio<1, 12>, foot::ratio>> {};
struct mile : derived_unit<mile, length, ratio_multiply<ratio<1'760>, yard::ratio>> {};
struct yard : derived_unit<yard, decltype("yd"_fs), length, ratio<9'144, 10'000>> {};
struct foot : derived_unit<foot, decltype("ft"_fs), length, ratio_multiply<ratio<1, 3>, yard::ratio>> {};
struct inch : derived_unit<inch, decltype("in"_fs), length, ratio_multiply<ratio<1, 12>, foot::ratio>> {};
struct mile : derived_unit<mile, decltype("mi"_fs), length, ratio_multiply<ratio<1'760>, yard::ratio>> {};
inline namespace literals {
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept LuminousIntensity = QuantityOf<T, luminous_intensity>;
struct candela : derived_unit<candela, luminous_intensity> {};
struct candela : derived_unit<candela, decltype("cd"_fs), luminous_intensity> {};
inline namespace literals {
+2 -2
View File
@@ -32,8 +32,8 @@ namespace units {
template<typename T>
concept Mass = QuantityOf<T, mass>;
struct gram : derived_unit<gram, mass, ratio<1, 1000>> {};
struct kilogram : derived_unit<kilogram, kilo<gram>> {};
struct gram : derived_unit<gram, decltype("g"_fs), mass, ratio<1, 1000>> {};
struct kilogram : derived_unit<kilogram, decltype("kg"_fs), kilo<gram>> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Power = QuantityOf<T, power>;
struct watt : derived_unit<watt, power, kilogram, metre, second> {};
struct watt : derived_unit<watt, decltype("W"_fs), power, kilogram, metre, second> {};
inline namespace literals {
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Pressure = QuantityOf<T, pressure>;
struct pascal : derived_unit<pascal, pressure, kilogram, metre, second> {};
struct pascal : derived_unit<pascal, decltype("Pa"_fs), pressure, kilogram, metre, second> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Substance = QuantityOf<T, substance>;
struct mole : derived_unit<mole, substance> {};
struct mole : derived_unit<mole, decltype("mol"_fs), substance> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept ThermodynamicTemperature = QuantityOf<T, temperature>;
struct kelvin : derived_unit<kelvin, temperature> {};
struct kelvin : derived_unit<kelvin, decltype("K"_fs), temperature> {};
inline namespace literals {
+6 -6
View File
@@ -32,12 +32,12 @@ namespace units {
template<typename T>
concept Time = QuantityOf<T, time>;
struct second : derived_unit<second, time> {};
struct nanosecond : derived_unit<nanosecond, nano<second>> {};
struct microsecond : derived_unit<microsecond, micro<second>> {};
struct millisecond : derived_unit<millisecond, milli<second>> {};
struct minute : derived_unit<minute, time, ratio<60>> {};
struct hour : derived_unit<hour, time, ratio<3600>> {};
struct second : derived_unit<second, decltype("s"_fs), time> {};
struct nanosecond : derived_unit<nanosecond, decltype("ns"_fs), nano<second>> {};
struct microsecond : derived_unit<microsecond, decltype("us"_fs), micro<second>> {};
struct millisecond : derived_unit<millisecond, decltype("ms"_fs), milli<second>> {};
struct minute : derived_unit<minute, decltype("min"_fs), time, ratio<60>> {};
struct hour : derived_unit<hour, decltype("h"_fs), time, ratio<3600>> {};
inline namespace literals {
+3 -3
View File
@@ -32,9 +32,9 @@ namespace units {
template<typename T>
concept Velocity = QuantityOf<T, velocity>;
struct metre_per_second : derived_unit<metre_per_second, velocity, metre, second> {};
struct kilometre_per_hour : derived_unit<kilometre_per_hour, velocity, kilometre, hour> {};
struct mile_per_hour : derived_unit<mile_per_hour, velocity, mile, hour> {};
struct metre_per_second : derived_unit<metre_per_second, decltype("m/s"_fs), velocity, metre, second> {};
struct kilometre_per_hour : derived_unit<kilometre_per_hour, decltype("km/h"_fs), velocity, kilometre, hour> {};
struct mile_per_hour : derived_unit<mile_per_hour, decltype("mi/h"_fs), velocity, mile, hour> {};
inline namespace literals {
+1 -1
View File
@@ -35,7 +35,7 @@ namespace units {
template<typename T>
concept Voltage = QuantityOf<T, voltage>;
struct volt : derived_unit<volt, voltage, kilogram, metre, second, ampere> {};
struct volt : derived_unit<volt, decltype("V"_fs), voltage, kilogram, metre, second, ampere> {};
inline namespace literals {
+9 -5
View File
@@ -31,11 +31,11 @@ namespace units {
template<typename T>
concept Volume = QuantityOf<T, volume>;
struct cubic_millimetre : derived_unit<cubic_millimetre, volume, millimetre> {};
struct cubic_centimetre : derived_unit<cubic_centimetre, volume, centimetre> {};
struct cubic_metre : derived_unit<cubic_metre, volume, metre> {};
struct cubic_kilometre : derived_unit<cubic_kilometre, volume, kilometre, metre> {};
struct cubic_foot : derived_unit<cubic_foot, volume, foot> {};
struct cubic_millimetre : derived_unit<cubic_millimetre, decltype("mm^3"_fs), volume, millimetre> {};
struct cubic_centimetre : derived_unit<cubic_centimetre, decltype("cm^3"_fs), volume, centimetre> {};
struct cubic_metre : derived_unit<cubic_metre, decltype("m^3"_fs), volume, metre> {};
struct cubic_kilometre : derived_unit<cubic_kilometre, decltype("km^3"_fs), volume, kilometre, metre> {};
struct cubic_foot : derived_unit<cubic_foot, decltype("ft^3"_fs), volume, foot> {};
inline namespace literals {
@@ -55,6 +55,10 @@ namespace units {
constexpr auto operator""cub_km(unsigned long long l) { return quantity<cubic_kilometre, std::int64_t>(l); }
constexpr auto operator""cub_km(long double l) { return quantity<cubic_kilometre, long double>(l); }
// cub_ft
constexpr auto operator""cub_ft(unsigned long long l) { return quantity<cubic_foot, std::int64_t>(l); }
constexpr auto operator""cub_ft(long double l) { return quantity<cubic_foot, long double>(l); }
} // namespace literals
} // namespace units