coherent_derived_unit and custom prefixes support added

This commit is contained in:
Mateusz Pusz committed 2019-10-17 10:16:44 +02:00
1 parent 9a9abca81d
commit 3e30c779a6
29 files changed
+261 -115

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, decltype("m/s^2"_fs), acceleration, metre, second> {};
struct metre_per_second_sq : coherent_derived_unit<metre_per_second_sq, decltype("m/s^2"_fs), acceleration> {};
inline namespace literals {
+5 -5
View File
@@ -31,14 +31,18 @@ namespace units {
template<typename T>
concept Area = QuantityOf<T, area>;
struct square_metre : coherent_derived_unit<square_metre, decltype("m^2"_fs), area> {};
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 {
// sq_m
constexpr auto operator""sq_m(unsigned long long l) { return quantity<square_metre, std::int64_t>(l); }
constexpr auto operator""sq_m(long double l) { return quantity<square_metre, long double>(l); }
// sq_mm
constexpr auto operator""sq_mm(unsigned long long l) { return quantity<square_millimetre, std::int64_t>(l); }
constexpr auto operator""sq_mm(long double l) { return quantity<square_millimetre, long double>(l); }
@@ -47,10 +51,6 @@ namespace units {
constexpr auto operator""sq_cm(unsigned long long l) { return quantity<square_centimetre, std::int64_t>(l); }
constexpr auto operator""sq_cm(long double l) { return quantity<square_centimetre, long double>(l); }
// sq_m
constexpr auto operator""sq_m(unsigned long long l) { return quantity<square_metre, std::int64_t>(l); }
constexpr auto operator""sq_m(long double l) { return quantity<square_metre, long double>(l); }
// sq_km
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); }
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Capacitance = QuantityOf<T, capacitance>;
struct farad : derived_unit<farad, decltype("F"_fs), capacitance, kilogram, metre, second, ampere> {};
struct farad : coherent_derived_unit<farad, decltype("F"_fs), capacitance, si_prefix> {};
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, decltype("A"_fs), current> {};
struct ampere : coherent_derived_unit<ampere, decltype("A"_fs), current, si_prefix> {};
inline namespace literals {
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept ElectricCharge = QuantityOf<T, electric_charge>;
struct coulomb : derived_unit<coulomb, decltype("C"_fs), electric_charge, second, ampere> {};
struct coulomb : coherent_derived_unit<coulomb, decltype("C"_fs), electric_charge, si_prefix> {};
inline namespace literals {
+2 -2
View File
@@ -27,13 +27,13 @@
#include <units/dimensions/pressure.h>
namespace units {
struct energy : derived_dimension<energy, exp<force, 1>, exp<length, 1>> {};
template<typename T>
concept Energy = QuantityOf<T, energy>;
struct joule : derived_unit<joule, decltype("J"_fs), energy, kilogram, metre, second> {};
struct joule : coherent_derived_unit<joule, decltype("J"_fs), energy, si_prefix> {};
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>> {};
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Force = QuantityOf<T, force>;
struct newton : derived_unit<newton, decltype("N"_fs), force, kilogram, metre, second> {};
struct newton : coherent_derived_unit<newton, decltype("N"_fs), force, si_prefix> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Frequency = QuantityOf<T, frequency>;
struct hertz : derived_unit<hertz, decltype("Hz"_fs), frequency, second> {};
struct hertz : coherent_derived_unit<hertz, decltype("Hz"_fs), frequency, si_prefix> {};
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>> {};
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
concept Length = QuantityOf<T, length>;
// SI units
struct metre : derived_unit<metre, decltype("m"_fs), length> {};
struct metre : coherent_derived_unit<metre, decltype("m"_fs), length, si_prefix> {};
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>> {};
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept LuminousIntensity = QuantityOf<T, luminous_intensity>;
struct candela : derived_unit<candela, decltype("cd"_fs), luminous_intensity> {};
struct candela : coherent_derived_unit<candela, decltype("cd"_fs), luminous_intensity, si_prefix> {};
inline namespace literals {
+1 -1
View File
@@ -32,8 +32,8 @@ namespace units {
template<typename T>
concept Mass = QuantityOf<T, mass>;
struct kilogram : coherent_derived_unit<kilogram, decltype("kg"_fs), mass> {};
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, decltype("W"_fs), power, kilogram, metre, second> {};
struct watt : coherent_derived_unit<watt, decltype("W"_fs), power, si_prefix> {};
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>> {};
+1 -1
View File
@@ -33,7 +33,7 @@ namespace units {
template<typename T>
concept Pressure = QuantityOf<T, pressure>;
struct pascal : derived_unit<pascal, decltype("Pa"_fs), pressure, kilogram, metre, second> {};
struct pascal : coherent_derived_unit<pascal, decltype("Pa"_fs), pressure, si_prefix> {};
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, decltype("mol"_fs), substance> {};
struct mole : coherent_derived_unit<mole, decltype("mol"_fs), substance, si_prefix> {};
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, decltype("K"_fs), temperature> {};
struct kelvin : coherent_derived_unit<kelvin, decltype("K"_fs), temperature> {};
inline namespace literals {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Time = QuantityOf<T, time>;
struct second : derived_unit<second, decltype("s"_fs), time> {};
struct second : coherent_derived_unit<second, decltype("s"_fs), time, si_prefix> {};
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>> {};
+1 -1
View File
@@ -32,7 +32,7 @@ namespace units {
template<typename T>
concept Velocity = QuantityOf<T, velocity>;
struct metre_per_second : derived_unit<metre_per_second, decltype("m/s"_fs), velocity, metre, second> {};
struct metre_per_second : coherent_derived_unit<metre_per_second, decltype("m/s"_fs), velocity> {};
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> {};
+1 -1
View File
@@ -35,7 +35,7 @@ namespace units {
template<typename T>
concept Voltage = QuantityOf<T, voltage>;
struct volt : derived_unit<volt, decltype("V"_fs), voltage, kilogram, metre, second, ampere> {};
struct volt : coherent_derived_unit<volt, decltype("V"_fs), voltage, si_prefix> {};
inline namespace literals {
+1 -1
View File
@@ -31,9 +31,9 @@ namespace units {
template<typename T>
concept Volume = QuantityOf<T, volume>;
struct cubic_metre : coherent_derived_unit<cubic_metre, decltype("m^3"_fs), volume> {};
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> {};