From 00d863508d524cc8365610c826f0e909e292ead8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 16 Dec 2019 15:58:41 +0100 Subject: [PATCH] base_dimension refactored - now stores dimension's symbol rather than its name - temperature and current renamed to exactly match their names in SI --- src/include/units/base_dimension.h | 14 ++++++------ src/include/units/bits/dimension_op.h | 2 +- src/include/units/concepts.h | 2 +- src/include/units/physical/dimensions.h | 22 +++++++++---------- src/include/units/physical/si/current.h | 4 ++-- .../units/physical/si/electric_charge.h | 2 +- src/include/units/physical/si/temperature.h | 4 ++-- src/include/units/physical/si/voltage.h | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/include/units/base_dimension.h b/src/include/units/base_dimension.h index 34546104..5b8d020f 100644 --- a/src/include/units/base_dimension.h +++ b/src/include/units/base_dimension.h @@ -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. * - * Pair of Name and Unit template parameter forms 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 + * 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 of a DerivedDimension * (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. * - * @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 */ -template +template requires U::is_named struct base_dimension { 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; }; @@ -60,7 +60,7 @@ struct base_dimension { // clang-format off template 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 } // namespace units diff --git a/src/include/units/bits/dimension_op.h b/src/include/units/bits/dimension_op.h index 6089dba6..8b01b2cd 100644 --- a/src/include/units/bits/dimension_op.h +++ b/src/include/units/bits/dimension_op.h @@ -34,7 +34,7 @@ template struct equivalent_dim_impl : std::false_type {}; template -struct equivalent_base_dim : std::conjunction, +struct equivalent_base_dim : std::conjunction, same_unit_reference> {}; template diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 00801715..76f8c654 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -89,7 +89,7 @@ template concept Unit = is_derived_from_instantiation; // BaseDimension -template +template requires U::is_named struct base_dimension; diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index 66460480..ea8ceb51 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -40,25 +40,25 @@ concept QuantityOf = Quantity && is_derived_from_instantiation -struct dim_length : base_dimension<"length", U> {}; +struct dim_length : base_dimension<"L", U> {}; template -struct dim_mass : base_dimension<"mass", U> {}; +struct dim_mass : base_dimension<"M", U> {}; template -struct dim_time : base_dimension<"time", U> {}; +struct dim_time : base_dimension<"T", U> {}; template -struct dim_current : base_dimension<"current", U> {}; +struct dim_electric_current : base_dimension<"I", U> {}; template -struct dim_temperature : base_dimension<"temperature", U> {}; +struct dim_thermodynamic_temperature : base_dimension<"Θ", U> {}; template -struct dim_substance : base_dimension<"substance", U> {}; +struct dim_substance : base_dimension<"N", U> {}; template -struct dim_luminous_intensity : base_dimension<"luminous intensity", U> {}; +struct dim_luminous_intensity : base_dimension<"J", U> {}; // ------------------------ derived dimensions ----------------------------- @@ -86,10 +86,10 @@ struct dim_energy : derived_dimension, exp> {}; template E, DimensionOf T> struct dim_power : derived_dimension, exp> {}; -template P, DimensionOf C> +template P, DimensionOf C> struct dim_voltage : derived_dimension, exp> {}; -template T, DimensionOf C> +template T, DimensionOf C> struct dim_electric_charge : derived_dimension, exp> {}; template C, DimensionOf V> @@ -113,10 +113,10 @@ template concept Time = physical::QuantityOf; template -concept Current = physical::QuantityOf; +concept Current = physical::QuantityOf; template -concept Temperature = physical::QuantityOf; +concept Temperature = physical::QuantityOf; template concept Substance = physical::QuantityOf; diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index 57580451..26b5143b 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -30,10 +30,10 @@ namespace units::si { struct ampere : named_unit {}; -struct dim_current : physical::dim_current {}; +struct dim_electric_current : physical::dim_electric_current {}; template -using current = quantity; +using current = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/electric_charge.h b/src/include/units/physical/si/electric_charge.h index 3b3c5de0..c2059c98 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -31,7 +31,7 @@ namespace units::si { struct coulomb : named_unit {}; -struct dim_electric_charge : physical::dim_electric_charge {}; +struct dim_electric_charge : physical::dim_electric_charge {}; template using electric_charge = quantity; diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index 27e6ab33..a00ef3b1 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -29,10 +29,10 @@ namespace units::si { struct kelvin : named_unit {}; -struct dim_temperature : physical::dim_temperature {}; +struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature {}; template -using temperature = quantity; +using temperature = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index 5e729032..7138e728 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -32,7 +32,7 @@ namespace units::si { struct volt : named_unit {}; -struct dim_voltage : physical::dim_voltage {}; +struct dim_voltage : physical::dim_voltage {}; template using voltage = quantity;