mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
base_dimension refactored
- now stores dimension's symbol rather than its name - temperature and current renamed to exactly match their names in SI
This commit is contained in:
@@ -38,20 +38,20 @@ namespace units {
|
|||||||
*
|
*
|
||||||
* Base unit is a measurement unit that is adopted by convention for a base quantity in a specific system of units.
|
* Base unit is a measurement unit that is adopted by convention for a base quantity in a specific system of units.
|
||||||
*
|
*
|
||||||
* Pair of Name and Unit template parameter forms an unique identifier of the base dimension. The same identifiers can
|
* Pair of Symbol and Unit template parameters form an unique identifier of the base dimension. The same identifiers can
|
||||||
* be multiplied and divided which will result with an adjustment of its factor in an Exponent od a DerivedDimension
|
* be multiplied and divided which will result with an adjustment of its factor in an Exponent of a DerivedDimension
|
||||||
* (in case of zero the dimension will be simplified and removed from further analysis of current expresion). In case
|
* (in case of zero the dimension will be simplified and removed from further analysis of current expresion). In case
|
||||||
* the Name is the same but the Unit differs (i.e. mixing SI and CGS length), there is no automatic simplification but
|
* the Symbol is the same but the Unit differs (i.e. mixing SI and CGS length), there is no automatic simplification but
|
||||||
* is possible to force it with a quantity_cast.
|
* is possible to force it with a quantity_cast.
|
||||||
*
|
*
|
||||||
* @tparam Name an unique identifier of the base dimension used to provide dimensional analysis support
|
* @tparam Symbol an unique identifier of the base dimension used to provide dimensional analysis support
|
||||||
* @tparam U a base unit to be used for this base dimension
|
* @tparam U a base unit to be used for this base dimension
|
||||||
*/
|
*/
|
||||||
template<basic_fixed_string Name, Unit U>
|
template<basic_fixed_string Symbol, Unit U>
|
||||||
requires U::is_named
|
requires U::is_named
|
||||||
struct base_dimension {
|
struct base_dimension {
|
||||||
using base_type_workaround = base_dimension; // TODO Replace with is_derived_from_instantiation when fixed
|
using base_type_workaround = base_dimension; // TODO Replace with is_derived_from_instantiation when fixed
|
||||||
static constexpr auto name = Name;
|
static constexpr auto symbol = Symbol;
|
||||||
using base_unit = U;
|
using base_unit = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ struct base_dimension {
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
template<BaseDimension D1, BaseDimension D2>
|
template<BaseDimension D1, BaseDimension D2>
|
||||||
struct base_dimension_less : std::bool_constant<
|
struct base_dimension_less : std::bool_constant<
|
||||||
D1::name < D2::name || (D1::name == D2::name && D1::base_unit::symbol < D1::base_unit::symbol)> {};
|
D1::symbol < D2::symbol || (D1::symbol == D2::symbol && D1::base_unit::symbol < D1::base_unit::symbol)> {};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
} // namespace units
|
} // namespace units
|
||||||
|
@@ -34,7 +34,7 @@ template<Dimension D1, Dimension D2>
|
|||||||
struct equivalent_dim_impl : std::false_type {};
|
struct equivalent_dim_impl : std::false_type {};
|
||||||
|
|
||||||
template<BaseDimension D1, BaseDimension D2>
|
template<BaseDimension D1, BaseDimension D2>
|
||||||
struct equivalent_base_dim : std::conjunction<std::bool_constant<D1::name == D2::name>,
|
struct equivalent_base_dim : std::conjunction<std::bool_constant<D1::symbol == D2::symbol>,
|
||||||
same_unit_reference<typename D1::base_unit, typename D2::base_unit>> {};
|
same_unit_reference<typename D1::base_unit, typename D2::base_unit>> {};
|
||||||
|
|
||||||
template<BaseDimension D1, BaseDimension D2>
|
template<BaseDimension D1, BaseDimension D2>
|
||||||
|
@@ -89,7 +89,7 @@ template<typename T>
|
|||||||
concept Unit = is_derived_from_instantiation<T, scaled_unit>;
|
concept Unit = is_derived_from_instantiation<T, scaled_unit>;
|
||||||
|
|
||||||
// BaseDimension
|
// BaseDimension
|
||||||
template<basic_fixed_string Name, Unit U>
|
template<basic_fixed_string Symbol, Unit U>
|
||||||
requires U::is_named
|
requires U::is_named
|
||||||
struct base_dimension;
|
struct base_dimension;
|
||||||
|
|
||||||
|
@@ -40,25 +40,25 @@ concept QuantityOf = Quantity<Q> && is_derived_from_instantiation<typename Q::di
|
|||||||
// ------------------------ base dimensions -----------------------------
|
// ------------------------ base dimensions -----------------------------
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_length : base_dimension<"length", U> {};
|
struct dim_length : base_dimension<"L", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_mass : base_dimension<"mass", U> {};
|
struct dim_mass : base_dimension<"M", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_time : base_dimension<"time", U> {};
|
struct dim_time : base_dimension<"T", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_current : base_dimension<"current", U> {};
|
struct dim_electric_current : base_dimension<"I", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_temperature : base_dimension<"temperature", U> {};
|
struct dim_thermodynamic_temperature : base_dimension<"Θ", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_substance : base_dimension<"substance", U> {};
|
struct dim_substance : base_dimension<"N", U> {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
struct dim_luminous_intensity : base_dimension<"luminous intensity", U> {};
|
struct dim_luminous_intensity : base_dimension<"J", U> {};
|
||||||
|
|
||||||
// ------------------------ derived dimensions -----------------------------
|
// ------------------------ derived dimensions -----------------------------
|
||||||
|
|
||||||
@@ -86,10 +86,10 @@ struct dim_energy : derived_dimension<Child, U, exp<F, 1>, exp<L, 1>> {};
|
|||||||
template<typename Child, Unit U, DimensionOf<dim_energy> E, DimensionOf<dim_time> T>
|
template<typename Child, Unit U, DimensionOf<dim_energy> E, DimensionOf<dim_time> T>
|
||||||
struct dim_power : derived_dimension<Child, U, exp<E, 1>, exp<T, -1>> {};
|
struct dim_power : derived_dimension<Child, U, exp<E, 1>, exp<T, -1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_power> P, DimensionOf<dim_current> C>
|
template<typename Child, Unit U, DimensionOf<dim_power> P, DimensionOf<dim_electric_current> C>
|
||||||
struct dim_voltage : derived_dimension<Child, U, exp<P, 1>, exp<C, -1>> {};
|
struct dim_voltage : derived_dimension<Child, U, exp<P, 1>, exp<C, -1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_time> T, DimensionOf<dim_current> C>
|
template<typename Child, Unit U, DimensionOf<dim_time> T, DimensionOf<dim_electric_current> C>
|
||||||
struct dim_electric_charge : derived_dimension<Child, U, exp<T, 1>, exp<C, 1>> {};
|
struct dim_electric_charge : derived_dimension<Child, U, exp<T, 1>, exp<C, 1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_electric_charge> C, DimensionOf<dim_voltage> V>
|
template<typename Child, Unit U, DimensionOf<dim_electric_charge> C, DimensionOf<dim_voltage> V>
|
||||||
@@ -113,10 +113,10 @@ template<typename T>
|
|||||||
concept Time = physical::QuantityOf<T, physical::dim_time>;
|
concept Time = physical::QuantityOf<T, physical::dim_time>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Current = physical::QuantityOf<T, physical::dim_current>;
|
concept Current = physical::QuantityOf<T, physical::dim_electric_current>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Temperature = physical::QuantityOf<T, physical::dim_temperature>;
|
concept Temperature = physical::QuantityOf<T, physical::dim_thermodynamic_temperature>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Substance = physical::QuantityOf<T, physical::dim_substance>;
|
concept Substance = physical::QuantityOf<T, physical::dim_substance>;
|
||||||
|
@@ -30,10 +30,10 @@ namespace units::si {
|
|||||||
|
|
||||||
struct ampere : named_unit<ampere, "m", prefix> {};
|
struct ampere : named_unit<ampere, "m", prefix> {};
|
||||||
|
|
||||||
struct dim_current : physical::dim_current<ampere> {};
|
struct dim_electric_current : physical::dim_electric_current<ampere> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using current = quantity<dim_current, U, Rep>;
|
using current = quantity<dim_electric_current, U, Rep>;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ namespace units::si {
|
|||||||
|
|
||||||
struct coulomb : named_unit<coulomb, "C", prefix> {};
|
struct coulomb : named_unit<coulomb, "C", prefix> {};
|
||||||
|
|
||||||
struct dim_electric_charge : physical::dim_electric_charge<dim_electric_charge, coulomb, dim_time, dim_current> {};
|
struct dim_electric_charge : physical::dim_electric_charge<dim_electric_charge, coulomb, dim_time, dim_electric_current> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using electric_charge = quantity<dim_electric_charge, U, Rep>;
|
using electric_charge = quantity<dim_electric_charge, U, Rep>;
|
||||||
|
@@ -29,10 +29,10 @@ namespace units::si {
|
|||||||
|
|
||||||
struct kelvin : named_unit<kelvin, "K", no_prefix> {};
|
struct kelvin : named_unit<kelvin, "K", no_prefix> {};
|
||||||
|
|
||||||
struct dim_temperature : physical::dim_temperature<kelvin> {};
|
struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature<kelvin> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using temperature = quantity<dim_temperature, U, Rep>;
|
using temperature = quantity<dim_thermodynamic_temperature, U, Rep>;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ namespace units::si {
|
|||||||
|
|
||||||
struct volt : named_unit<volt, "V", prefix> {};
|
struct volt : named_unit<volt, "V", prefix> {};
|
||||||
|
|
||||||
struct dim_voltage : physical::dim_voltage<dim_voltage, volt, dim_power, dim_current> {};
|
struct dim_voltage : physical::dim_voltage<dim_voltage, volt, dim_power, dim_electric_current> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using voltage = quantity<dim_voltage, U, Rep>;
|
using voltage = quantity<dim_voltage, U, Rep>;
|
||||||
|
Reference in New Issue
Block a user