refactor: 💥 ! unit renamed to derived_unit

This commit is contained in:
Mateusz Pusz
2022-05-11 11:40:19 +02:00
parent f5d21a0711
commit 0522bae972
35 changed files with 54 additions and 54 deletions

View File

@@ -65,20 +65,6 @@ using downcast_unit = downcast<scaled_unit<R, typename dimension_unit<D>::refere
template<Unit U1, Unit U2>
struct same_unit_reference : is_same<typename U1::reference, typename U2::reference> {};
/**
* @brief An unnamed unit
*
* Defines a new unnamed (in most cases coherent) derived unit of a specific derived dimension
* and it should be passed in this dimension's definition.
*
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
*/
template<typename Child>
struct unit : downcast_dispatch<Child, scaled_unit<ratio(1), Child>> {
static constexpr bool is_named = false;
using prefix_family = no_prefix;
};
/**
* @brief A named unit
*
@@ -139,6 +125,20 @@ struct prefixed_unit : downcast_dispatch<Child, scaled_unit<P::ratio * U::ratio,
using prefix_family = no_prefix;
};
/**
* @brief A coherent unit of a derived quantity
*
* Defines a new coherent unit of a derived quantity. It should be passed as a coherent unit
* in the dimension's definition for such a quantity.
*
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
*/
template<typename Child>
struct derived_unit : downcast_dispatch<Child, scaled_unit<ratio(1), Child>> {
static constexpr bool is_named = false;
using prefix_family = no_prefix;
};
/**
* @brief A unit with a deduced ratio and symbol
*
@@ -209,6 +209,6 @@ struct prefixed_alias_unit : U {
*
* Used as a coherent unit of an unknown dimension.
*/
struct unknown_coherent_unit : unit<unknown_coherent_unit> {};
struct unknown_coherent_unit : derived_unit<unknown_coherent_unit> {};
} // namespace units

View File

@@ -34,7 +34,7 @@
namespace units::isq::iec80000 {
struct byte_per_second : unit<byte_per_second> {};
struct byte_per_second : derived_unit<byte_per_second> {};
struct dim_transfer_rate :
derived_dimension<dim_transfer_rate, byte_per_second, exponent<dim_storage_capacity, 1>,
exponent<si::dim_time, -1>> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::cgs {
struct erg_per_second : unit<erg_per_second> {};
struct erg_per_second : derived_unit<erg_per_second> {};
struct dim_power : isq::dim_power<dim_power, erg_per_second, dim_energy, dim_time> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::cgs {
struct centimetre_per_second : unit<centimetre_per_second> {};
struct centimetre_per_second : derived_unit<centimetre_per_second> {};
struct dim_speed : isq::dim_speed<dim_speed, centimetre_per_second, dim_length, dim_time> {};
template<UnitOf<dim_speed> U, Representation Rep = double>

View File

@@ -33,7 +33,7 @@
namespace units::isq::si::fps {
struct foot_per_second_sq : unit<foot_per_second_sq> {};
struct foot_per_second_sq : derived_unit<foot_per_second_sq> {};
struct dim_acceleration : isq::dim_acceleration<dim_acceleration, foot_per_second_sq, dim_length, dim_time> {};
template<UnitOf<dim_acceleration> U, Representation Rep = double>

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::fps {
struct square_foot : unit<square_foot> {};
struct square_foot : derived_unit<square_foot> {};
struct dim_area : isq::dim_area<dim_area, square_foot, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::fps {
struct pound_per_foot_cub : unit<pound_per_foot_cub> {};
struct pound_per_foot_cub : derived_unit<pound_per_foot_cub> {};
struct dim_density : isq::dim_density<dim_density, pound_per_foot_cub, dim_mass, dim_length> {};

View File

@@ -35,7 +35,7 @@
namespace units::isq::si::fps {
// https://en.wikipedia.org/wiki/Foot-poundal
struct foot_poundal : unit<foot_poundal> {};
struct foot_poundal : derived_unit<foot_poundal> {};
struct dim_energy : isq::dim_energy<dim_energy, foot_poundal, dim_length, dim_force> {};

View File

@@ -35,7 +35,7 @@
namespace units::isq::si::fps {
struct foot_poundal_per_second : unit<foot_poundal_per_second> {};
struct foot_poundal_per_second : derived_unit<foot_poundal_per_second> {};
struct dim_power : isq::dim_power<dim_power, foot_poundal_per_second, dim_length, dim_force, dim_time> {};

View File

@@ -36,7 +36,7 @@
namespace units::isq::si::fps {
struct poundal_per_foot_sq : unit<poundal_per_foot_sq> {};
struct poundal_per_foot_sq : derived_unit<poundal_per_foot_sq> {};
struct dim_pressure : isq::dim_pressure<dim_pressure, poundal_per_foot_sq, dim_force, dim_area> {};

View File

@@ -35,7 +35,7 @@
namespace units::isq::si::fps {
struct foot_per_second : unit<foot_per_second> {};
struct foot_per_second : derived_unit<foot_per_second> {};
struct dim_speed : isq::dim_speed<dim_speed, foot_per_second, dim_length, dim_time> {};
template<UnitOf<dim_speed> U, Representation Rep = double>

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::fps {
struct cubic_foot : unit<cubic_foot> {};
struct cubic_foot : derived_unit<cubic_foot> {};
struct dim_volume : isq::dim_volume<dim_volume, cubic_foot, dim_length> {};
struct cubic_yard : derived_deduced_unit<cubic_yard, dim_volume, yard> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si::hep {
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
struct kilogram_metre_per_second : derived_unit<kilogram_metre_per_second> {};
struct eV_per_c :
named_scaled_unit<eV_per_c, "eV/c", prefix, ratio(5'344'285'992'678, 1'000'000'000'000, -35),

View File

@@ -33,7 +33,7 @@
namespace units::isq::si {
struct metre_per_second_sq : unit<metre_per_second_sq> {};
struct metre_per_second_sq : derived_unit<metre_per_second_sq> {};
struct dim_acceleration : isq::dim_acceleration<dim_acceleration, metre_per_second_sq, dim_length, dim_time> {};
template<UnitOf<dim_acceleration> U, Representation Rep = double>

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct square_metre : unit<square_metre> {};
struct square_metre : derived_unit<square_metre> {};
struct dim_area : isq::dim_area<dim_area, square_metre, dim_length> {};
struct square_yoctometre : derived_deduced_unit<square_yoctometre, dim_area, yoctometre> {};

View File

@@ -35,8 +35,8 @@
namespace units::isq::si {
struct coulomb_per_metre_cub : unit<coulomb_per_metre_cub> {};
struct coulomb_per_metre_sq : unit<coulomb_per_metre_sq> {};
struct coulomb_per_metre_cub : derived_unit<coulomb_per_metre_cub> {};
struct coulomb_per_metre_sq : derived_unit<coulomb_per_metre_sq> {};
struct dim_charge_density :
isq::dim_charge_density<dim_charge_density, coulomb_per_metre_cub, dim_electric_charge, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct mol_per_metre_cub : unit<mol_per_metre_cub> {};
struct mol_per_metre_cub : derived_unit<mol_per_metre_cub> {};
struct dim_concentration :
isq::dim_concentration<dim_concentration, mol_per_metre_cub, dim_amount_of_substance, dim_length> {};

View File

@@ -35,7 +35,7 @@
namespace units::isq::si {
struct ampere_per_metre_sq : unit<ampere_per_metre_sq> {};
struct ampere_per_metre_sq : derived_unit<ampere_per_metre_sq> {};
struct dim_current_density :
isq::dim_current_density<dim_current_density, ampere_per_metre_sq, dim_electric_current, dim_length> {};

View File

@@ -35,7 +35,7 @@
namespace units::isq::si {
struct kilogram_per_metre_cub : unit<kilogram_per_metre_cub> {};
struct kilogram_per_metre_cub : derived_unit<kilogram_per_metre_cub> {};
struct dim_density : isq::dim_density<dim_density, kilogram_per_metre_cub, dim_mass, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct pascal_second : unit<pascal_second> {};
struct pascal_second : derived_unit<pascal_second> {};
struct dim_dynamic_viscosity :
isq::dim_dynamic_viscosity<dim_dynamic_viscosity, pascal_second, dim_pressure, dim_time> {};

View File

@@ -33,7 +33,7 @@
namespace units::isq::si {
struct volt_per_metre : unit<volt_per_metre> {};
struct volt_per_metre : derived_unit<volt_per_metre> {};
struct dim_electric_field_strength :
isq::dim_electric_field_strength<dim_electric_field_strength, volt_per_metre, dim_voltage, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct joule_per_metre_cub : unit<joule_per_metre_cub> {};
struct joule_per_metre_cub : derived_unit<joule_per_metre_cub> {};
struct dim_energy_density : isq::dim_energy_density<dim_energy_density, joule_per_metre_cub, dim_energy, dim_volume> {};
template<UnitOf<dim_energy_density> U, Representation Rep = double>

View File

@@ -36,9 +36,9 @@
namespace units::isq::si {
struct joule_per_kelvin : unit<joule_per_kelvin> {};
struct joule_per_kilogram_kelvin : unit<joule_per_kilogram_kelvin> {};
struct joule_per_mole_kelvin : unit<joule_per_mole_kelvin> {};
struct joule_per_kelvin : derived_unit<joule_per_kelvin> {};
struct joule_per_kilogram_kelvin : derived_unit<joule_per_kilogram_kelvin> {};
struct joule_per_mole_kelvin : derived_unit<joule_per_mole_kelvin> {};
struct dim_heat_capacity :
isq::dim_heat_capacity<dim_heat_capacity, joule_per_kelvin, dim_energy, dim_thermodynamic_temperature> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct candela_per_metre_sq : unit<candela_per_metre_sq> {};
struct candela_per_metre_sq : derived_unit<candela_per_metre_sq> {};
struct dim_luminance : isq::dim_luminance<dim_luminance, candela_per_metre_sq, dim_luminous_intensity, dim_length> {};
template<UnitOf<dim_luminance> U, Representation Rep = double>

View File

@@ -35,7 +35,7 @@
namespace units::isq::si {
struct joule_per_mole : unit<joule_per_mole> {};
struct joule_per_mole : derived_unit<joule_per_mole> {};
struct dim_molar_energy :
isq::dim_molar_energy<dim_molar_energy, joule_per_mole, dim_energy, dim_amount_of_substance> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
struct kilogram_metre_per_second : derived_unit<kilogram_metre_per_second> {};
struct dim_momentum : isq::dim_momentum<dim_momentum, kilogram_metre_per_second, dim_mass, dim_speed> {};
template<UnitOf<dim_momentum> U, Representation Rep = double>

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct henry_per_metre : unit<henry_per_metre> {};
struct henry_per_metre : derived_unit<henry_per_metre> {};
struct dim_permeability : isq::dim_permeability<dim_permeability, henry_per_metre, dim_inductance, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct farad_per_metre : unit<farad_per_metre> {};
struct farad_per_metre : derived_unit<farad_per_metre> {};
struct dim_permittivity : isq::dim_permittivity<dim_permittivity, farad_per_metre, dim_capacitance, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct metre_per_second : unit<metre_per_second> {};
struct metre_per_second : derived_unit<metre_per_second> {};
struct dim_speed : isq::dim_speed<dim_speed, metre_per_second, dim_length, dim_time> {};
struct kilometre_per_hour : derived_deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};

View File

@@ -33,7 +33,7 @@
namespace units::isq::si {
struct newton_per_metre : unit<newton_per_metre> {};
struct newton_per_metre : derived_unit<newton_per_metre> {};
struct dim_surface_tension : isq::dim_surface_tension<dim_surface_tension, newton_per_metre, dim_force, dim_length> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct watt_per_metre_kelvin : unit<watt_per_metre_kelvin> {};
struct watt_per_metre_kelvin : derived_unit<watt_per_metre_kelvin> {};
struct dim_thermal_conductivity :
isq::dim_thermal_conductivity<dim_thermal_conductivity, watt_per_metre_kelvin, dim_power, dim_length,

View File

@@ -35,7 +35,7 @@
namespace units::isq::si {
struct newton_metre_per_radian : unit<newton_metre_per_radian> {};
struct newton_metre_per_radian : derived_unit<newton_metre_per_radian> {};
struct dim_torque : isq::dim_torque<dim_torque, newton_metre_per_radian, dim_force, dim_length, dim_angle<>> {};

View File

@@ -34,7 +34,7 @@
namespace units::isq::si {
struct cubic_metre : unit<cubic_metre> {};
struct cubic_metre : derived_unit<cubic_metre> {};
struct dim_volume : isq::dim_volume<dim_volume, cubic_metre, dim_length> {};
struct cubic_yoctometre : derived_deduced_unit<cubic_yoctometre, dim_volume, yoctometre> {};

View File

@@ -36,7 +36,7 @@ using namespace units;
using namespace units::isq::si;
// power spectral density
struct sq_volt_per_hertz : unit<sq_volt_per_hertz> {};
struct sq_volt_per_hertz : derived_unit<sq_volt_per_hertz> {};
struct dim_power_spectral_density :
derived_dimension<dim_power_spectral_density, sq_volt_per_hertz, units::exponent<dim_voltage, 2>,
units::exponent<dim_frequency, -1>> {};
@@ -45,7 +45,7 @@ template<UnitOf<dim_power_spectral_density> U, Representation Rep = double>
using power_spectral_density = quantity<dim_power_spectral_density, U, Rep>;
// amplitude spectral density
struct volt_per_sqrt_hertz : unit<volt_per_sqrt_hertz> {};
struct volt_per_sqrt_hertz : derived_unit<volt_per_sqrt_hertz> {};
struct dim_amplitude_spectral_density :
derived_dimension<dim_amplitude_spectral_density, volt_per_sqrt_hertz, units::exponent<dim_voltage, 1>,
units::exponent<dim_frequency, -1, 2>> {};
@@ -69,7 +69,7 @@ static_assert(compare<decltype(sqrt(power_spectral_density<sq_volt_per_hertz>(16
namespace {
struct kilogram_per_second : unit<kilogram_per_second> {};
struct kilogram_per_second : derived_unit<kilogram_per_second> {};
struct dim_mass_rate :
derived_dimension<dim_mass_rate, kilogram_per_second, units::exponent<dim_mass, 1>, units::exponent<dim_time, -1>> {
};

View File

@@ -52,7 +52,7 @@ static_assert([]<Prefix P>(P) {
}(si::kilo{})); // no prefix allowed
#endif
struct metre_per_second : unit<metre_per_second> {};
struct metre_per_second : derived_unit<metre_per_second> {};
struct dim_speed :
derived_dimension<dim_speed, metre_per_second, units::exponent<dim_length, 1>, units::exponent<dim_time, -1>> {};
struct kilometre_per_hour : derived_deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};