QuantityOf concept added

This commit is contained in:
Mateusz Pusz
2019-09-10 22:33:54 +02:00
parent bce17a8476
commit bebaa5482c
20 changed files with 22 additions and 19 deletions

View File

@ -30,7 +30,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<acceleration>> : downcast_to<acceleration> {};
template<typename T>
concept bool Acceleration = Quantity<T> && std::same_as<typename T::dimension, acceleration>;
concept bool Acceleration = QuantityOf<T, acceleration>;
struct metre_per_second_sq : derived_unit<acceleration, metre, second> {};
template<> struct downcasting_traits<downcast_from<metre_per_second_sq>> : downcast_to<metre_per_second_sq> {};

View File

@ -30,7 +30,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<area>> : downcast_to<area> {};
template<typename T>
concept bool Area = Quantity<T> && std::same_as<typename T::dimension, area>;
concept bool Area = QuantityOf<T, area>;
struct square_millimetre : derived_unit<area, millimetre> {};
template<> struct downcasting_traits<downcast_from<square_millimetre>> : downcast_to<square_millimetre> {};

View File

@ -32,7 +32,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<capacitance>> : downcast_to<capacitance> {};
template<typename T>
concept bool Capacitance = Quantity<T> && std::same_as<typename T::dimension, capacitance>;
concept bool Capacitance = QuantityOf<T, capacitance>;
struct farad : derived_unit<capacitance, kilogram, metre, second, ampere> {};
template<> struct downcasting_traits<downcast_from<farad>> : downcast_to<farad> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<current>> : downcast_to<current> {};
template<typename T>
concept bool Current = Quantity<T> && std::same_as<typename T::dimension, current>;
concept bool Current = QuantityOf<T, current>;
struct ampere : unit<current> {};
template<> struct downcasting_traits<downcast_from<ampere>> : downcast_to<ampere> {};

View File

@ -32,7 +32,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<electric_charge>> : downcast_to<electric_charge> {};
template<typename T>
concept bool ElectricCharge = Quantity<T> && std::same_as<typename T::dimension, electric_charge>;
concept bool ElectricCharge = QuantityOf<T, electric_charge>;
struct coulomb : derived_unit<electric_charge, second, ampere> {};
template<> struct downcasting_traits<downcast_from<coulomb>> : downcast_to<coulomb> {};

View File

@ -32,7 +32,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<energy>> : downcast_to<energy> {};
template<typename T>
concept bool Energy = Quantity<T> && std::same_as<typename T::dimension, energy>;
concept bool Energy = QuantityOf<T, energy>;
struct joule : derived_unit<energy, kilogram, metre, second> {};
template<> struct downcasting_traits<downcast_from<joule>> : downcast_to<joule> {};

View File

@ -33,7 +33,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<force>> : downcast_to<force> {};
template<typename T>
concept bool Force = Quantity<T> && std::same_as<typename T::dimension, force>;
concept bool Force = QuantityOf<T, force>;
struct newton : derived_unit<force, kilogram, metre, second> {};
template<> struct downcasting_traits<downcast_from<newton>> : downcast_to<newton> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<frequency>> : downcast_to<frequency> {};
template<typename T>
concept bool Frequency = Quantity<T> && std::same_as<typename T::dimension, frequency>;
concept bool Frequency = QuantityOf<T, frequency>;
struct hertz : derived_unit<frequency, second> {};
template<> struct downcasting_traits<downcast_from<hertz>> : downcast_to<hertz> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<length>> : downcast_to<length> {};
template<typename T>
concept bool Length = Quantity<T> && std::same_as<typename T::dimension, length>;
concept bool Length = QuantityOf<T, length>;
// SI units
struct metre : unit<length> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<luminous_intensity>> : downcast_to<luminous_intensity> {};
template<typename T>
concept bool LuminousIntensity = Quantity<T> && std::same_as<typename T::dimension, luminous_intensity>;
concept bool LuminousIntensity = QuantityOf<T, luminous_intensity>;
struct candela : unit<luminous_intensity> {};
template<> struct downcasting_traits<downcast_from<candela>> : downcast_to<candela> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<mass>> : downcast_to<mass> {};
template<typename T>
concept bool Mass = Quantity<T> && std::same_as<typename T::dimension, mass>;
concept bool Mass = QuantityOf<T, mass>;
struct gram : unit<mass, ratio<1, 1000>> {};
template<> struct downcasting_traits<downcast_from<gram>> : downcast_to<gram> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<power>> : downcast_to<power> {};
template<typename T>
concept bool Power = Quantity<T> && std::same_as<typename T::dimension, power>;
concept bool Power = QuantityOf<T, power>;
struct watt : derived_unit<power, kilogram, metre, second> {};
template<> struct downcasting_traits<downcast_from<watt>> : downcast_to<watt> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<pressure>> : downcast_to<pressure> {};
template<typename T>
concept bool Pressure = Quantity<T> && std::same_as<typename T::dimension, pressure>;
concept bool Pressure = QuantityOf<T, pressure>;
struct pascal : derived_unit<pressure, kilogram, metre, second> {};
template<> struct downcasting_traits<downcast_from<pascal>> : downcast_to<pascal> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<substance>> : downcast_to<substance> {};
template<typename T>
concept bool Substance = Quantity<T> && std::same_as<typename T::dimension, substance>;
concept bool Substance = QuantityOf<T, substance>;
struct mole : unit<substance> {};
template<> struct downcasting_traits<downcast_from<mole>> : downcast_to<mole> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<temperature>> : downcast_to<temperature> {};
template<typename T>
concept bool ThermodynamicTemperature = Quantity<T> && std::same_as<typename T::dimension, temperature>;
concept bool ThermodynamicTemperature = QuantityOf<T, temperature>;
struct kelvin : unit<temperature> {};
template<> struct downcasting_traits<downcast_from<kelvin>> : downcast_to<kelvin> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<time>> : downcast_to<time> {};
template<typename T>
concept bool Time = Quantity<T> && std::same_as<typename T::dimension, time>;
concept bool Time = QuantityOf<T, time>;
struct second : unit<time> {};
template<> struct downcasting_traits<downcast_from<second>> : downcast_to<second> {};

View File

@ -31,7 +31,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<velocity>> : downcast_to<velocity> {};
template<typename T>
concept bool Velocity = Quantity<T> && std::same_as<typename T::dimension, velocity>;
concept bool Velocity = QuantityOf<T, velocity>;
struct metre_per_second : derived_unit<velocity, metre, second> {};
template<> struct downcasting_traits<downcast_from<metre_per_second>> : downcast_to<metre_per_second> {};

View File

@ -34,7 +34,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<voltage>> : downcast_to<voltage> {};
template<typename T>
concept bool Voltage = Quantity<T> && std::same_as<typename T::dimension, voltage>;
concept bool Voltage = QuantityOf<T, voltage>;
struct volt : derived_unit<voltage, kilogram, metre, second, ampere> {};
template<> struct downcasting_traits<downcast_from<volt>> : downcast_to<volt> {};

View File

@ -30,7 +30,7 @@ namespace std::experimental::units {
template<> struct downcasting_traits<downcast_from<volume>> : downcast_to<volume> {};
template<typename T>
concept bool Volume = Quantity<T> && std::same_as<typename T::dimension, volume>;
concept bool Volume = QuantityOf<T, volume>;
struct cubic_millimetre : derived_unit<volume, millimetre> {};
template<> struct downcasting_traits<downcast_from<cubic_millimetre>> : downcast_to<cubic_millimetre> {};

View File

@ -41,6 +41,9 @@ namespace std::experimental::units {
template<typename T>
concept bool Quantity = detail::is_quantity<T>;
template<typename T, typename D>
concept bool QuantityOf = Quantity<T> && Dimension<D> && std::same_as<typename T::dimension, D>;
// Scalar
template<typename T>