From 9838705e315dc63eabcaf47672aa26380fa076d4 Mon Sep 17 00:00:00 2001 From: Andy Little Date: Tue, 2 Jun 2020 23:04:53 +0100 Subject: [PATCH 1/6] Rename Scalar concept to Value. Fixes https://github.com/mpusz/units/issues/114 --- example/linear_algebra.cpp | 6 +-- example/measurement.cpp | 2 +- src/include/units/bits/common_quantity.h | 4 +- src/include/units/concepts.h | 4 +- src/include/units/customization_points.h | 4 +- src/include/units/data/bitrate.h | 2 +- src/include/units/data/information.h | 2 +- src/include/units/physical/cgs/acceleration.h | 2 +- src/include/units/physical/cgs/area.h | 2 +- src/include/units/physical/cgs/energy.h | 2 +- src/include/units/physical/cgs/force.h | 2 +- src/include/units/physical/cgs/length.h | 2 +- src/include/units/physical/cgs/mass.h | 2 +- src/include/units/physical/cgs/power.h | 2 +- src/include/units/physical/cgs/pressure.h | 2 +- src/include/units/physical/cgs/speed.h | 2 +- .../units/physical/natural/constants.h | 2 +- .../units/physical/natural/dimensions.h | 16 +++--- src/include/units/physical/si/absorbed_dose.h | 2 +- src/include/units/physical/si/acceleration.h | 2 +- src/include/units/physical/si/angle.h | 2 +- src/include/units/physical/si/area.h | 2 +- src/include/units/physical/si/capacitance.h | 2 +- .../units/physical/si/catalytic_activity.h | 2 +- .../units/physical/si/charge_density.h | 4 +- src/include/units/physical/si/concentration.h | 2 +- src/include/units/physical/si/conductance.h | 2 +- src/include/units/physical/si/constants.h | 18 +++---- src/include/units/physical/si/current.h | 2 +- .../units/physical/si/current_density.h | 2 +- src/include/units/physical/si/density.h | 2 +- .../units/physical/si/dynamic_viscosity.h | 2 +- .../units/physical/si/electric_charge.h | 2 +- .../physical/si/electric_field_strength.h | 2 +- src/include/units/physical/si/energy.h | 2 +- src/include/units/physical/si/force.h | 2 +- src/include/units/physical/si/frequency.h | 2 +- src/include/units/physical/si/heat_capacity.h | 6 +-- src/include/units/physical/si/inductance.h | 2 +- src/include/units/physical/si/length.h | 2 +- src/include/units/physical/si/luminance.h | 2 +- .../units/physical/si/luminous_intensity.h | 2 +- src/include/units/physical/si/magnetic_flux.h | 2 +- .../units/physical/si/magnetic_induction.h | 2 +- src/include/units/physical/si/mass.h | 2 +- src/include/units/physical/si/molar_energy.h | 2 +- src/include/units/physical/si/momentum.h | 2 +- src/include/units/physical/si/permeability.h | 2 +- src/include/units/physical/si/permittivity.h | 2 +- src/include/units/physical/si/power.h | 2 +- src/include/units/physical/si/pressure.h | 2 +- src/include/units/physical/si/resistance.h | 2 +- src/include/units/physical/si/speed.h | 2 +- src/include/units/physical/si/substance.h | 2 +- .../units/physical/si/surface_tension.h | 2 +- src/include/units/physical/si/temperature.h | 2 +- .../units/physical/si/thermal_conductivity.h | 2 +- src/include/units/physical/si/time.h | 2 +- src/include/units/physical/si/torque.h | 2 +- src/include/units/physical/si/voltage.h | 2 +- src/include/units/physical/si/volume.h | 2 +- src/include/units/quantity.h | 54 +++++++++---------- src/include/units/quantity_cast.h | 2 +- .../static/custom_rep_min_req_test.cpp | 10 ++-- test/unit_test/static/custom_unit_test.cpp | 4 +- 65 files changed, 119 insertions(+), 119 deletions(-) diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 8bd693384..50f7a5cd9 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -201,10 +201,10 @@ void matrix_of_quantity_tests() matrix_of_quantity_divide_by_scalar(); } -template +template using length_v = si::length>; -template +template using force_v = si::force>; void quantity_of_vector_add() @@ -274,7 +274,7 @@ void quantity_of_vector_tests() quantity_of_vector_divide_by_scalar(); } -template +template using length_m = si::length>; void quantity_of_matrix_add() diff --git a/example/measurement.cpp b/example/measurement.cpp index 372a5e57a..a3e72f29e 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -146,7 +146,7 @@ class measurement { value_type uncertainty_{}; }; -static_assert(units::Scalar>); +static_assert(units::Value>); } // namespace diff --git a/src/include/units/bits/common_quantity.h b/src/include/units/bits/common_quantity.h index 30d271939..1a9fca7e2 100644 --- a/src/include/units/bits/common_quantity.h +++ b/src/include/units/bits/common_quantity.h @@ -26,7 +26,7 @@ namespace units { -template U, Scalar Rep> +template U, Value Rep> class quantity; namespace detail { @@ -59,7 +59,7 @@ struct common_quantity_impl, quantity, Rep> } // namespace detail -template> +template> requires equivalent_dim using common_quantity = detail::common_quantity_impl::type; diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 435292f3e..653d77d8e 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -253,7 +253,7 @@ inline constexpr bool is_wrapped_quantity = Quantity template concept WrappedQuantity = detail::is_wrapped_quantity; -// Scalar +// Value namespace detail { @@ -283,7 +283,7 @@ concept not_constructible_from_integral = * Satisfied by types that satisfy `(!Quantity) && (!WrappedQuantity) && std::regular`. */ template -concept Scalar = +concept Value = (!Quantity) && (!WrappedQuantity) && std::regular && diff --git a/src/include/units/customization_points.h b/src/include/units/customization_points.h index 02237684c..f7a021e29 100644 --- a/src/include/units/customization_points.h +++ b/src/include/units/customization_points.h @@ -37,7 +37,7 @@ namespace units { * * @tparam Rep a representation type for which a type trait is defined */ -template +template inline constexpr bool treat_as_floating_point = std::is_floating_point_v; /** @@ -49,7 +49,7 @@ inline constexpr bool treat_as_floating_point = std::is_floating_point_v; * * @tparam Rep a representation type for which a type trait is defined */ -template +template struct quantity_values { static constexpr Rep zero() noexcept { return Rep(0); } static constexpr Rep one() noexcept { return Rep(1); } diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index fa2068aff..2d1800a4d 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -41,7 +41,7 @@ struct pebibit_per_second : deduced_unit concept Bitrate = QuantityOf; -template +template using bitrate = quantity; inline namespace literals { diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index 8ecd35314..34b85c025 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -48,7 +48,7 @@ struct dim_information : base_dimension<"information", bit> {}; template concept Information = QuantityOf; -template +template using information = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index c3609212f..315ac41eb 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::cgs { struct gal : named_unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/area.h b/src/include/units/physical/cgs/area.h index 1f52edabe..d203ccc19 100644 --- a/src/include/units/physical/cgs/area.h +++ b/src/include/units/physical/cgs/area.h @@ -33,7 +33,7 @@ using si::square_centimetre; struct dim_area : physical::dim_area {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/energy.h b/src/include/units/physical/cgs/energy.h index 9c2908982..773c6f996 100644 --- a/src/include/units/physical/cgs/energy.h +++ b/src/include/units/physical/cgs/energy.h @@ -33,7 +33,7 @@ struct erg : named_unit {}; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index ec3e2d7e8..514b4ece0 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -34,7 +34,7 @@ struct dyne : named_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index c5d824681..94628b0da 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -32,7 +32,7 @@ using si::centimetre; struct dim_length : physical::dim_length {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/mass.h b/src/include/units/physical/cgs/mass.h index 1ad0456b0..77ff76350 100644 --- a/src/include/units/physical/cgs/mass.h +++ b/src/include/units/physical/cgs/mass.h @@ -32,7 +32,7 @@ using si::gram; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index 6a1c9c2e6..a6a795b7a 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -33,7 +33,7 @@ struct erg_per_second : unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/pressure.h b/src/include/units/physical/cgs/pressure.h index 0c07b3dc4..0593ea338 100644 --- a/src/include/units/physical/cgs/pressure.h +++ b/src/include/units/physical/cgs/pressure.h @@ -34,7 +34,7 @@ struct barye : named_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/speed.h b/src/include/units/physical/cgs/speed.h index 5c07f2027..c47bfcacc 100644 --- a/src/include/units/physical/cgs/speed.h +++ b/src/include/units/physical/cgs/speed.h @@ -32,7 +32,7 @@ namespace units::physical::cgs { struct centimetre_per_second : unit {}; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/natural/constants.h b/src/include/units/physical/natural/constants.h index afcb89de1..e48fa6ad5 100644 --- a/src/include/units/physical/natural/constants.h +++ b/src/include/units/physical/natural/constants.h @@ -26,7 +26,7 @@ namespace units::physical::natural { -template +template inline constexpr auto speed_of_light = speed(1); } // namespace units::physical::natural diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index 4ec305d57..d0100ad3f 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -29,35 +29,35 @@ namespace units::physical::natural { struct dim_length : physical::dim_length {}; -template +template using length = quantity; struct dim_time : physical::dim_time {}; -template +template using time = quantity; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; struct dim_force : physical::dim_force {}; -template +template using force = quantity; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; // Typical UDLs will not work here as the same units are reused by many quantities. diff --git a/src/include/units/physical/si/absorbed_dose.h b/src/include/units/physical/si/absorbed_dose.h index 956c8609f..a8ae0db51 100644 --- a/src/include/units/physical/si/absorbed_dose.h +++ b/src/include/units/physical/si/absorbed_dose.h @@ -54,7 +54,7 @@ struct yottagray : prefixed_unit {}; struct dim_absorbed_dose : physical::dim_absorbed_dose {}; -template +template using absorbed_dose = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index cdb6bbc5d..a1509154a 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct metre_per_second_sq : unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/angle.h b/src/include/units/physical/si/angle.h index e3ecb4808..c81e85338 100644 --- a/src/include/units/physical/si/angle.h +++ b/src/include/units/physical/si/angle.h @@ -32,7 +32,7 @@ struct radian : named_unit {}; struct dim_angle : physical::dim_angle {}; -template +template using angle = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index 34fb9f4db..8e3d32dcd 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -54,7 +54,7 @@ struct square_yottametre : deduced_unit struct hectare : alias_unit {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/capacitance.h b/src/include/units/physical/si/capacitance.h index 640da58c0..091e0fc67 100644 --- a/src/include/units/physical/si/capacitance.h +++ b/src/include/units/physical/si/capacitance.h @@ -54,7 +54,7 @@ struct yottafarad : prefixed_unit {}; struct dim_capacitance : physical::dim_capacitance {}; -template +template using capacitance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/catalytic_activity.h b/src/include/units/physical/si/catalytic_activity.h index 7ae6c0ed5..9484cdb29 100644 --- a/src/include/units/physical/si/catalytic_activity.h +++ b/src/include/units/physical/si/catalytic_activity.h @@ -56,7 +56,7 @@ struct enzyme_unit : named_scaled_unit {}; -template +template using catalytic_activity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/charge_density.h b/src/include/units/physical/si/charge_density.h index 04ba4a455..de5ff8005 100644 --- a/src/include/units/physical/si/charge_density.h +++ b/src/include/units/physical/si/charge_density.h @@ -36,10 +36,10 @@ struct coulomb_per_metre_sq : unit {}; struct dim_charge_density : physical::dim_charge_density {}; struct dim_surface_charge_density : physical::dim_surface_charge_density {}; -template +template using charge_density = quantity; -template +template using surface_charge_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/concentration.h b/src/include/units/physical/si/concentration.h index 4c6c62207..c91e189cd 100644 --- a/src/include/units/physical/si/concentration.h +++ b/src/include/units/physical/si/concentration.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct mol_per_metre_cub : unit {}; struct dim_concentration : physical::dim_concentration {}; -template +template using concentration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/conductance.h b/src/include/units/physical/si/conductance.h index dd7b16b4a..5ebd12096 100644 --- a/src/include/units/physical/si/conductance.h +++ b/src/include/units/physical/si/conductance.h @@ -49,7 +49,7 @@ struct yottasiemens : prefixed_unit {}; struct dim_conductance : physical::dim_conductance {}; -template +template using conductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/constants.h b/src/include/units/physical/si/constants.h index 750a1d4b0..d0f54957e 100644 --- a/src/include/units/physical/si/constants.h +++ b/src/include/units/physical/si/constants.h @@ -32,31 +32,31 @@ namespace units::physical::si::si2019 { -template +template inline constexpr auto planck_constant = energy(6.62607015e-34) * time(1); -template +template inline constexpr auto reduced_planck_constant = energy(6.582119569e-10) * time(1); -template +template inline constexpr auto elementary_charge = electric_charge(1.602176634e-19); -template +template inline constexpr auto boltzmann_constant = energy(1.380649e-23) / temperature(1); -template +template inline constexpr auto avogadro_constant = Rep(6.02214076e23) / substance(1); -template +template inline constexpr auto speed_of_light = speed(299'792'458); -template +template inline constexpr auto hyperfine_structure_transition_frequency = frequency(9'192'631'770); -// template +// template // inline constexpr auto luminous_efficacy = 683q_lm / 1q_W; -template +template inline constexpr auto standard_gravity = acceleration(9.80665); } // namespace units::physical::si::si2019 diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index b4349006f..bf0d052bc 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -52,7 +52,7 @@ struct yottaampere : prefixed_unit {}; struct dim_electric_current : physical::dim_electric_current {}; -template +template using current = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/current_density.h b/src/include/units/physical/si/current_density.h index 157c5cec3..f3c6b3c9a 100644 --- a/src/include/units/physical/si/current_density.h +++ b/src/include/units/physical/si/current_density.h @@ -34,7 +34,7 @@ struct ampere_per_metre_sq : unit {}; struct dim_current_density : physical::dim_current_density {}; -template +template using current_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/density.h b/src/include/units/physical/si/density.h index 794076113..0714fe6b0 100644 --- a/src/include/units/physical/si/density.h +++ b/src/include/units/physical/si/density.h @@ -34,7 +34,7 @@ struct kilogram_per_metre_cub : unit {}; struct dim_density : physical::dim_density {}; -template +template using density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/dynamic_viscosity.h b/src/include/units/physical/si/dynamic_viscosity.h index 412b4fe38..f22d739d6 100644 --- a/src/include/units/physical/si/dynamic_viscosity.h +++ b/src/include/units/physical/si/dynamic_viscosity.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct pascal_second : unit {}; struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity {}; -template +template using dynamic_viscosity = 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 1bdc153b2..9b4574322 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -33,7 +33,7 @@ struct coulomb : named_unit {}; struct dim_electric_charge : physical::dim_electric_charge {}; -template +template using electric_charge = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/electric_field_strength.h b/src/include/units/physical/si/electric_field_strength.h index dead39671..f400a933d 100644 --- a/src/include/units/physical/si/electric_field_strength.h +++ b/src/include/units/physical/si/electric_field_strength.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct volt_per_metre : unit {}; struct dim_electric_field_strength : physical::dim_electric_field_strength {}; -template +template using electric_field_strength = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index 548489466..4691a7847 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -52,7 +52,7 @@ struct gigaelectronvolt : prefixed_unit {} struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/force.h b/src/include/units/physical/si/force.h index 835b39a9a..d093c11ea 100644 --- a/src/include/units/physical/si/force.h +++ b/src/include/units/physical/si/force.h @@ -54,7 +54,7 @@ struct yottanewton : prefixed_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/frequency.h b/src/include/units/physical/si/frequency.h index c75d82138..c3ebdaf10 100644 --- a/src/include/units/physical/si/frequency.h +++ b/src/include/units/physical/si/frequency.h @@ -48,7 +48,7 @@ struct yottahertz : prefixed_unit {}; struct dim_frequency : physical::dim_frequency {}; -template +template using frequency = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/heat_capacity.h b/src/include/units/physical/si/heat_capacity.h index 878973142..db7f414e3 100644 --- a/src/include/units/physical/si/heat_capacity.h +++ b/src/include/units/physical/si/heat_capacity.h @@ -39,13 +39,13 @@ struct dim_heat_capacity : physical::dim_heat_capacity {}; struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity {}; -template +template using heat_capacity = quantity; -template +template using specific_heat_capacity = quantity; -template +template using molar_heat_capacity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/inductance.h b/src/include/units/physical/si/inductance.h index 105a17cb8..8a394df8c 100644 --- a/src/include/units/physical/si/inductance.h +++ b/src/include/units/physical/si/inductance.h @@ -50,7 +50,7 @@ struct yottahenry : prefixed_unit {}; struct dim_inductance : physical::dim_inductance {}; -template +template using inductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index a5c51a67d..2e5b433f0 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -54,7 +54,7 @@ struct astronomical_unit : named_scaled_unit {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminance.h b/src/include/units/physical/si/luminance.h index 2af847c03..04634eb80 100644 --- a/src/include/units/physical/si/luminance.h +++ b/src/include/units/physical/si/luminance.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct candela_per_metre_sq : unit {}; struct dim_luminance : physical::dim_luminance {}; -template +template using luminance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminous_intensity.h b/src/include/units/physical/si/luminous_intensity.h index 0cca63000..a736f3d9b 100644 --- a/src/include/units/physical/si/luminous_intensity.h +++ b/src/include/units/physical/si/luminous_intensity.h @@ -52,7 +52,7 @@ struct yottacandela : prefixed_unit {}; struct dim_luminous_intensity : physical::dim_luminous_intensity {}; -template +template using luminous_intensity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_flux.h b/src/include/units/physical/si/magnetic_flux.h index 433db1eeb..ceb3d0793 100644 --- a/src/include/units/physical/si/magnetic_flux.h +++ b/src/include/units/physical/si/magnetic_flux.h @@ -50,7 +50,7 @@ struct yottaweber : prefixed_unit {}; struct dim_magnetic_flux : physical::dim_magnetic_flux {}; -template +template using magnetic_flux = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_induction.h b/src/include/units/physical/si/magnetic_induction.h index fc20a69ba..80eeb18ee 100644 --- a/src/include/units/physical/si/magnetic_induction.h +++ b/src/include/units/physical/si/magnetic_induction.h @@ -54,7 +54,7 @@ struct gauss : named_scaled_unit, tesla> {} struct dim_magnetic_induction : physical::dim_magnetic_induction {}; -template +template using magnetic_induction = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index 7a5e33373..a78d5caa9 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -76,7 +76,7 @@ struct dalton : named_scaled_unit {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/molar_energy.h b/src/include/units/physical/si/molar_energy.h index 6d8b5d641..dd06960b1 100644 --- a/src/include/units/physical/si/molar_energy.h +++ b/src/include/units/physical/si/molar_energy.h @@ -34,7 +34,7 @@ struct joule_per_mole : unit {}; struct dim_molar_energy : physical::dim_molar_energy {}; -template +template using molar_energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h index 0e15dbf6d..a0146f08c 100644 --- a/src/include/units/physical/si/momentum.h +++ b/src/include/units/physical/si/momentum.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct kilogram_metre_per_second : unit {}; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permeability.h b/src/include/units/physical/si/permeability.h index 752acf042..449794655 100644 --- a/src/include/units/physical/si/permeability.h +++ b/src/include/units/physical/si/permeability.h @@ -33,7 +33,7 @@ struct henry_per_metre : unit {}; struct dim_permeability : physical::dim_permeability {}; -template +template using permeability = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permittivity.h b/src/include/units/physical/si/permittivity.h index 2f31fc261..daf03c6a8 100644 --- a/src/include/units/physical/si/permittivity.h +++ b/src/include/units/physical/si/permittivity.h @@ -33,7 +33,7 @@ struct farad_per_metre : unit {}; struct dim_permittivity : physical::dim_permittivity {}; -template +template using permittivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/power.h b/src/include/units/physical/si/power.h index 62c952395..c678e1d80 100644 --- a/src/include/units/physical/si/power.h +++ b/src/include/units/physical/si/power.h @@ -49,7 +49,7 @@ struct yottawatt : prefixed_unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index 6f68ce52c..90125eb6e 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -54,7 +54,7 @@ struct yottapascal : prefixed_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/resistance.h b/src/include/units/physical/si/resistance.h index f096b0fe6..45569e37a 100644 --- a/src/include/units/physical/si/resistance.h +++ b/src/include/units/physical/si/resistance.h @@ -50,7 +50,7 @@ struct yottaohm : prefixed_unit {}; struct dim_resistance : physical::dim_resistance {}; -template +template using resistance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/speed.h b/src/include/units/physical/si/speed.h index 46ce7189d..8d13a8554 100644 --- a/src/include/units/physical/si/speed.h +++ b/src/include/units/physical/si/speed.h @@ -34,7 +34,7 @@ struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/substance.h b/src/include/units/physical/si/substance.h index e3d0348ef..b58451b2b 100644 --- a/src/include/units/physical/si/substance.h +++ b/src/include/units/physical/si/substance.h @@ -32,7 +32,7 @@ struct mole : named_unit {}; struct dim_substance : physical::dim_substance {}; -template +template using substance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/surface_tension.h b/src/include/units/physical/si/surface_tension.h index 77befa13f..7fb04b2b7 100644 --- a/src/include/units/physical/si/surface_tension.h +++ b/src/include/units/physical/si/surface_tension.h @@ -32,7 +32,7 @@ struct newton_per_metre : unit {}; struct dim_surface_tension : physical::dim_surface_tension {}; -template +template using surface_tension = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index cf016ebc4..763704757 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -31,7 +31,7 @@ struct kelvin : named_unit {}; struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature {}; -template +template using temperature = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/thermal_conductivity.h b/src/include/units/physical/si/thermal_conductivity.h index b74f0b878..9f54ca7ae 100644 --- a/src/include/units/physical/si/thermal_conductivity.h +++ b/src/include/units/physical/si/thermal_conductivity.h @@ -33,7 +33,7 @@ struct watt_per_metre_kelvin : unit {}; struct dim_thermal_conductivity : physical::dim_thermal_conductivity {}; -template +template using thermal_conductivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index b3778bd82..198a67522 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -43,7 +43,7 @@ struct day : named_scaled_unit, hour> {}; struct dim_time : physical::dim_time {}; -template +template using time = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/torque.h b/src/include/units/physical/si/torque.h index c6fbe4d88..4f18fae1a 100644 --- a/src/include/units/physical/si/torque.h +++ b/src/include/units/physical/si/torque.h @@ -34,7 +34,7 @@ struct newton_metre : named_unit {}; struct dim_torque : physical::dim_torque {}; -template +template using torque = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index b974ddfde..da48ec194 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -54,7 +54,7 @@ struct yottavolt : prefixed_unit {}; struct dim_voltage : physical::dim_voltage {}; -template +template using voltage = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/volume.h b/src/include/units/physical/si/volume.h index ad5affc81..047088e21 100644 --- a/src/include/units/physical/si/volume.h +++ b/src/include/units/physical/si/volume.h @@ -74,7 +74,7 @@ struct exalitre : prefixed_unit {}; struct zettalitre : prefixed_alias_unit {}; struct yottalitre : prefixed_unit {}; -template +template using volume = quantity; inline namespace literals { diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index e497c8f17..17e19cf9d 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -60,7 +60,7 @@ concept safe_divisible = // exposition only * @tparam U a measurement unit of the quantity * @tparam Rep a type to be used to represent values of a quantity */ -template U, Scalar Rep = double> +template U, Value Rep = double> class quantity { Rep value_{}; @@ -73,9 +73,9 @@ class quantity { quantity(const quantity&) = default; quantity(quantity&&) = default; - template - requires detail::safe_convertible - constexpr explicit quantity(const Value& v) : value_{static_cast(v)} {} + template + requires detail::safe_convertible + constexpr explicit quantity(const Val& v) : value_{static_cast(v)} {} template requires equivalent_dim && @@ -200,11 +200,11 @@ class quantity { return *this; } - template - constexpr quantity& operator%=(const Value& rhs) + template + constexpr quantity& operator%=(const Val& rhs) requires (!treat_as_floating_point) && - (!treat_as_floating_point) && - requires(T v1, Value v2) { { v1 %= v2 } -> SAME_AS(T&); } + (!treat_as_floating_point) && + requires(T v1, Val v2) { { v1 %= v2 } -> SAME_AS(T&); } // requires(rep v1, Value v2) { { v1 %= v2 } -> SAME_AS(rep&); } // TODO gated by gcc-9 (fixed in gcc-10) { value_ %= rhs; @@ -322,24 +322,24 @@ template return ret(ret(lhs).count() - ret(rhs).count()); } -template -[[nodiscard]] constexpr Quantity AUTO operator*(const quantity& q, const Value& v) - requires std::regular_invocable, Rep, Value> +template +[[nodiscard]] constexpr Quantity AUTO operator*(const quantity& q, const Val& v) + requires std::regular_invocable, Rep, Val> { using common_rep = decltype(q.count() * v); using ret = quantity; return ret(q.count() * v); } -template -[[nodiscard]] constexpr Quantity AUTO operator*(const Value& v, const quantity& q) - requires std::regular_invocable, Value, Rep> +template +[[nodiscard]] constexpr Quantity AUTO operator*(const Val& v, const quantity& q) + requires std::regular_invocable, Val, Rep> { return q * v; } template -[[nodiscard]] constexpr Scalar AUTO operator*(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr Value AUTO operator*(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim> { @@ -366,9 +366,9 @@ template -[[nodiscard]] constexpr Quantity AUTO operator/(const Value& v, const quantity& q) - requires std::regular_invocable, Value, Rep> +template +[[nodiscard]] constexpr Quantity AUTO operator/(const Val& v, const quantity& q) + requires std::regular_invocable, Val, Rep> { Expects(q.count() != 0); @@ -380,11 +380,11 @@ template return ret(v / q.count()); } -template -[[nodiscard]] constexpr Quantity AUTO operator/(const quantity& q, const Value& v) - requires std::regular_invocable, Rep, Value> +template +[[nodiscard]] constexpr Quantity AUTO operator/(const quantity& q, const Val& v) + requires std::regular_invocable, Rep, Val> { - Expects(v != Value{0}); + Expects(v != Val{0}); using common_rep = decltype(q.count() / v); using ret = quantity; @@ -392,7 +392,7 @@ template } template -[[nodiscard]] constexpr Scalar AUTO operator/(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr Value AUTO operator/(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim { @@ -419,11 +419,11 @@ template -[[nodiscard]] constexpr Quantity AUTO operator%(const quantity& q, const Value& v) +template +[[nodiscard]] constexpr Quantity AUTO operator%(const quantity& q, const Val& v) requires (!treat_as_floating_point) && - (!treat_as_floating_point) && - std::regular_invocable, Rep, Value> + (!treat_as_floating_point) && + std::regular_invocable, Rep, Val> { using common_rep = decltype(q.count() % v); using ret = quantity; diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index 7235ebb61..004cf8843 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -386,7 +386,7 @@ template * * @tparam ToRep a representation type to use for a target quantity */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) { return quantity_cast>(q); diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index d9a12ce5b..005184d6a 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -85,7 +85,7 @@ using impl_impl = impl_constructible_impl_convertible; static_assert(std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::Scalar>); +static_assert(units::Value>); template struct expl_constructible_impl_convertible : scalar_ops> { @@ -100,7 +100,7 @@ using expl_impl = expl_constructible_impl_convertible; static_assert(!std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::Scalar>); +static_assert(units::Value>); template struct impl_constructible_expl_convertible : scalar_ops> { @@ -115,7 +115,7 @@ using impl_expl = impl_constructible_expl_convertible; static_assert(std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::Scalar>); +static_assert(units::Value>); template struct expl_constructible_expl_convertible : scalar_ops> { @@ -130,7 +130,7 @@ using expl_expl = expl_constructible_expl_convertible; static_assert(!std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::Scalar>); +static_assert(units::Value>); } // namespace @@ -169,7 +169,7 @@ using namespace units::physical::si; // constructors -// Quantity from Scalar +// Quantity from Value // int <- int static_assert(length(expl_impl(1)).count() == 1); // static_assert(length(impl_expl(1)).count() == 1); // should not compile (not convertible) diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index b2e4aff1f..016fa1e2e 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -35,14 +35,14 @@ using namespace units::physical::si; struct sq_volt_per_hertz : unit {}; struct dim_power_spectral_density : derived_dimension, units::exp> {}; -template +template using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; struct dim_amplitude_spectral_density : derived_dimension, units::exp> {}; -template +template using amplitude_spectral_density = quantity; } From a60d69b979ca90251107d4e1594eb2ad356a10bf Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 7 Jun 2020 11:52:20 +0100 Subject: [PATCH 2/6] rename Value concept to NumericValue --- example/linear_algebra.cpp | 6 ++--- example/measurement.cpp | 2 +- src/include/units/bits/common_quantity.h | 4 ++-- src/include/units/concepts.h | 4 ++-- src/include/units/customization_points.h | 4 ++-- src/include/units/data/bitrate.h | 2 +- src/include/units/data/information.h | 2 +- src/include/units/physical/cgs/acceleration.h | 2 +- src/include/units/physical/cgs/area.h | 2 +- src/include/units/physical/cgs/energy.h | 2 +- src/include/units/physical/cgs/force.h | 2 +- src/include/units/physical/cgs/length.h | 2 +- src/include/units/physical/cgs/mass.h | 2 +- src/include/units/physical/cgs/power.h | 2 +- src/include/units/physical/cgs/pressure.h | 2 +- src/include/units/physical/cgs/speed.h | 2 +- .../units/physical/natural/constants.h | 2 +- .../units/physical/natural/dimensions.h | 16 +++++++------- src/include/units/physical/si/absorbed_dose.h | 2 +- src/include/units/physical/si/acceleration.h | 2 +- src/include/units/physical/si/angle.h | 2 +- src/include/units/physical/si/area.h | 2 +- src/include/units/physical/si/capacitance.h | 2 +- .../units/physical/si/catalytic_activity.h | 2 +- .../units/physical/si/charge_density.h | 4 ++-- src/include/units/physical/si/concentration.h | 2 +- src/include/units/physical/si/conductance.h | 2 +- src/include/units/physical/si/constants.h | 18 +++++++-------- src/include/units/physical/si/current.h | 2 +- .../units/physical/si/current_density.h | 2 +- src/include/units/physical/si/density.h | 2 +- .../units/physical/si/dynamic_viscosity.h | 2 +- .../units/physical/si/electric_charge.h | 2 +- .../physical/si/electric_field_strength.h | 2 +- src/include/units/physical/si/energy.h | 2 +- src/include/units/physical/si/force.h | 2 +- src/include/units/physical/si/frequency.h | 2 +- src/include/units/physical/si/heat_capacity.h | 6 ++--- src/include/units/physical/si/inductance.h | 2 +- src/include/units/physical/si/length.h | 2 +- src/include/units/physical/si/luminance.h | 2 +- .../units/physical/si/luminous_intensity.h | 2 +- src/include/units/physical/si/magnetic_flux.h | 2 +- .../units/physical/si/magnetic_induction.h | 2 +- src/include/units/physical/si/mass.h | 2 +- src/include/units/physical/si/molar_energy.h | 2 +- src/include/units/physical/si/momentum.h | 2 +- src/include/units/physical/si/permeability.h | 2 +- src/include/units/physical/si/permittivity.h | 2 +- src/include/units/physical/si/power.h | 2 +- src/include/units/physical/si/pressure.h | 2 +- src/include/units/physical/si/resistance.h | 2 +- src/include/units/physical/si/speed.h | 2 +- src/include/units/physical/si/substance.h | 2 +- .../units/physical/si/surface_tension.h | 2 +- src/include/units/physical/si/temperature.h | 2 +- .../units/physical/si/thermal_conductivity.h | 2 +- src/include/units/physical/si/time.h | 2 +- src/include/units/physical/si/torque.h | 2 +- src/include/units/physical/si/voltage.h | 2 +- src/include/units/physical/si/volume.h | 2 +- src/include/units/quantity.h | 22 +++++++++---------- src/include/units/quantity_cast.h | 2 +- .../static/custom_rep_min_req_test.cpp | 10 ++++----- test/unit_test/static/custom_unit_test.cpp | 4 ++-- 65 files changed, 103 insertions(+), 103 deletions(-) diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 50f7a5cd9..2024e51d9 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -201,10 +201,10 @@ void matrix_of_quantity_tests() matrix_of_quantity_divide_by_scalar(); } -template +template using length_v = si::length>; -template +template using force_v = si::force>; void quantity_of_vector_add() @@ -274,7 +274,7 @@ void quantity_of_vector_tests() quantity_of_vector_divide_by_scalar(); } -template +template using length_m = si::length>; void quantity_of_matrix_add() diff --git a/example/measurement.cpp b/example/measurement.cpp index a3e72f29e..a5399817d 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -146,7 +146,7 @@ class measurement { value_type uncertainty_{}; }; -static_assert(units::Value>); +static_assert(units::NumericValue>); } // namespace diff --git a/src/include/units/bits/common_quantity.h b/src/include/units/bits/common_quantity.h index 1a9fca7e2..e66f79b9b 100644 --- a/src/include/units/bits/common_quantity.h +++ b/src/include/units/bits/common_quantity.h @@ -26,7 +26,7 @@ namespace units { -template U, Value Rep> +template U, NumericValue Rep> class quantity; namespace detail { @@ -59,7 +59,7 @@ struct common_quantity_impl, quantity, Rep> } // namespace detail -template> +template> requires equivalent_dim using common_quantity = detail::common_quantity_impl::type; diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 653d77d8e..271f915f2 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -253,7 +253,7 @@ inline constexpr bool is_wrapped_quantity = Quantity template concept WrappedQuantity = detail::is_wrapped_quantity; -// Value +// NumericValue namespace detail { @@ -283,7 +283,7 @@ concept not_constructible_from_integral = * Satisfied by types that satisfy `(!Quantity) && (!WrappedQuantity) && std::regular`. */ template -concept Value = +concept NumericValue = (!Quantity) && (!WrappedQuantity) && std::regular && diff --git a/src/include/units/customization_points.h b/src/include/units/customization_points.h index f7a021e29..82fe56ffd 100644 --- a/src/include/units/customization_points.h +++ b/src/include/units/customization_points.h @@ -37,7 +37,7 @@ namespace units { * * @tparam Rep a representation type for which a type trait is defined */ -template +template inline constexpr bool treat_as_floating_point = std::is_floating_point_v; /** @@ -49,7 +49,7 @@ inline constexpr bool treat_as_floating_point = std::is_floating_point_v; * * @tparam Rep a representation type for which a type trait is defined */ -template +template struct quantity_values { static constexpr Rep zero() noexcept { return Rep(0); } static constexpr Rep one() noexcept { return Rep(1); } diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index 2d1800a4d..cdf9483cb 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -41,7 +41,7 @@ struct pebibit_per_second : deduced_unit concept Bitrate = QuantityOf; -template +template using bitrate = quantity; inline namespace literals { diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index 34b85c025..d2c65df86 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -48,7 +48,7 @@ struct dim_information : base_dimension<"information", bit> {}; template concept Information = QuantityOf; -template +template using information = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index 315ac41eb..a0cc45893 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::cgs { struct gal : named_unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/area.h b/src/include/units/physical/cgs/area.h index d203ccc19..4aaf7fed1 100644 --- a/src/include/units/physical/cgs/area.h +++ b/src/include/units/physical/cgs/area.h @@ -33,7 +33,7 @@ using si::square_centimetre; struct dim_area : physical::dim_area {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/energy.h b/src/include/units/physical/cgs/energy.h index 773c6f996..0dc284547 100644 --- a/src/include/units/physical/cgs/energy.h +++ b/src/include/units/physical/cgs/energy.h @@ -33,7 +33,7 @@ struct erg : named_unit {}; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index 514b4ece0..8720641e9 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -34,7 +34,7 @@ struct dyne : named_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index 94628b0da..75639f76e 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -32,7 +32,7 @@ using si::centimetre; struct dim_length : physical::dim_length {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/mass.h b/src/include/units/physical/cgs/mass.h index 77ff76350..6ef55d4a4 100644 --- a/src/include/units/physical/cgs/mass.h +++ b/src/include/units/physical/cgs/mass.h @@ -32,7 +32,7 @@ using si::gram; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index a6a795b7a..a37295252 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -33,7 +33,7 @@ struct erg_per_second : unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/pressure.h b/src/include/units/physical/cgs/pressure.h index 0593ea338..a7c956b13 100644 --- a/src/include/units/physical/cgs/pressure.h +++ b/src/include/units/physical/cgs/pressure.h @@ -34,7 +34,7 @@ struct barye : named_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/speed.h b/src/include/units/physical/cgs/speed.h index c47bfcacc..7bbce4398 100644 --- a/src/include/units/physical/cgs/speed.h +++ b/src/include/units/physical/cgs/speed.h @@ -32,7 +32,7 @@ namespace units::physical::cgs { struct centimetre_per_second : unit {}; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/natural/constants.h b/src/include/units/physical/natural/constants.h index e48fa6ad5..a7aa0b07d 100644 --- a/src/include/units/physical/natural/constants.h +++ b/src/include/units/physical/natural/constants.h @@ -26,7 +26,7 @@ namespace units::physical::natural { -template +template inline constexpr auto speed_of_light = speed(1); } // namespace units::physical::natural diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index d0100ad3f..fac8f26ce 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -29,35 +29,35 @@ namespace units::physical::natural { struct dim_length : physical::dim_length {}; -template +template using length = quantity; struct dim_time : physical::dim_time {}; -template +template using time = quantity; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; struct dim_force : physical::dim_force {}; -template +template using force = quantity; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; // Typical UDLs will not work here as the same units are reused by many quantities. diff --git a/src/include/units/physical/si/absorbed_dose.h b/src/include/units/physical/si/absorbed_dose.h index a8ae0db51..8b480bf53 100644 --- a/src/include/units/physical/si/absorbed_dose.h +++ b/src/include/units/physical/si/absorbed_dose.h @@ -54,7 +54,7 @@ struct yottagray : prefixed_unit {}; struct dim_absorbed_dose : physical::dim_absorbed_dose {}; -template +template using absorbed_dose = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index a1509154a..e3297088f 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct metre_per_second_sq : unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/angle.h b/src/include/units/physical/si/angle.h index c81e85338..c021a7e9d 100644 --- a/src/include/units/physical/si/angle.h +++ b/src/include/units/physical/si/angle.h @@ -32,7 +32,7 @@ struct radian : named_unit {}; struct dim_angle : physical::dim_angle {}; -template +template using angle = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index 8e3d32dcd..71ef9364e 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -54,7 +54,7 @@ struct square_yottametre : deduced_unit struct hectare : alias_unit {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/capacitance.h b/src/include/units/physical/si/capacitance.h index 091e0fc67..0a0637f86 100644 --- a/src/include/units/physical/si/capacitance.h +++ b/src/include/units/physical/si/capacitance.h @@ -54,7 +54,7 @@ struct yottafarad : prefixed_unit {}; struct dim_capacitance : physical::dim_capacitance {}; -template +template using capacitance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/catalytic_activity.h b/src/include/units/physical/si/catalytic_activity.h index 9484cdb29..952abfb43 100644 --- a/src/include/units/physical/si/catalytic_activity.h +++ b/src/include/units/physical/si/catalytic_activity.h @@ -56,7 +56,7 @@ struct enzyme_unit : named_scaled_unit {}; -template +template using catalytic_activity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/charge_density.h b/src/include/units/physical/si/charge_density.h index de5ff8005..653bab627 100644 --- a/src/include/units/physical/si/charge_density.h +++ b/src/include/units/physical/si/charge_density.h @@ -36,10 +36,10 @@ struct coulomb_per_metre_sq : unit {}; struct dim_charge_density : physical::dim_charge_density {}; struct dim_surface_charge_density : physical::dim_surface_charge_density {}; -template +template using charge_density = quantity; -template +template using surface_charge_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/concentration.h b/src/include/units/physical/si/concentration.h index c91e189cd..ac7038e2a 100644 --- a/src/include/units/physical/si/concentration.h +++ b/src/include/units/physical/si/concentration.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct mol_per_metre_cub : unit {}; struct dim_concentration : physical::dim_concentration {}; -template +template using concentration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/conductance.h b/src/include/units/physical/si/conductance.h index 5ebd12096..7b3676cd8 100644 --- a/src/include/units/physical/si/conductance.h +++ b/src/include/units/physical/si/conductance.h @@ -49,7 +49,7 @@ struct yottasiemens : prefixed_unit {}; struct dim_conductance : physical::dim_conductance {}; -template +template using conductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/constants.h b/src/include/units/physical/si/constants.h index d0f54957e..5c02a2e0e 100644 --- a/src/include/units/physical/si/constants.h +++ b/src/include/units/physical/si/constants.h @@ -32,31 +32,31 @@ namespace units::physical::si::si2019 { -template +template inline constexpr auto planck_constant = energy(6.62607015e-34) * time(1); -template +template inline constexpr auto reduced_planck_constant = energy(6.582119569e-10) * time(1); -template +template inline constexpr auto elementary_charge = electric_charge(1.602176634e-19); -template +template inline constexpr auto boltzmann_constant = energy(1.380649e-23) / temperature(1); -template +template inline constexpr auto avogadro_constant = Rep(6.02214076e23) / substance(1); -template +template inline constexpr auto speed_of_light = speed(299'792'458); -template +template inline constexpr auto hyperfine_structure_transition_frequency = frequency(9'192'631'770); -// template +// template // inline constexpr auto luminous_efficacy = 683q_lm / 1q_W; -template +template inline constexpr auto standard_gravity = acceleration(9.80665); } // namespace units::physical::si::si2019 diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index bf0d052bc..79955cb69 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -52,7 +52,7 @@ struct yottaampere : prefixed_unit {}; struct dim_electric_current : physical::dim_electric_current {}; -template +template using current = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/current_density.h b/src/include/units/physical/si/current_density.h index f3c6b3c9a..573ad58d7 100644 --- a/src/include/units/physical/si/current_density.h +++ b/src/include/units/physical/si/current_density.h @@ -34,7 +34,7 @@ struct ampere_per_metre_sq : unit {}; struct dim_current_density : physical::dim_current_density {}; -template +template using current_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/density.h b/src/include/units/physical/si/density.h index 0714fe6b0..735a89600 100644 --- a/src/include/units/physical/si/density.h +++ b/src/include/units/physical/si/density.h @@ -34,7 +34,7 @@ struct kilogram_per_metre_cub : unit {}; struct dim_density : physical::dim_density {}; -template +template using density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/dynamic_viscosity.h b/src/include/units/physical/si/dynamic_viscosity.h index f22d739d6..3255cf093 100644 --- a/src/include/units/physical/si/dynamic_viscosity.h +++ b/src/include/units/physical/si/dynamic_viscosity.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct pascal_second : unit {}; struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity {}; -template +template using dynamic_viscosity = 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 9b4574322..50742e4ab 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -33,7 +33,7 @@ struct coulomb : named_unit {}; struct dim_electric_charge : physical::dim_electric_charge {}; -template +template using electric_charge = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/electric_field_strength.h b/src/include/units/physical/si/electric_field_strength.h index f400a933d..8578f576e 100644 --- a/src/include/units/physical/si/electric_field_strength.h +++ b/src/include/units/physical/si/electric_field_strength.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct volt_per_metre : unit {}; struct dim_electric_field_strength : physical::dim_electric_field_strength {}; -template +template using electric_field_strength = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index 4691a7847..466663eb5 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -52,7 +52,7 @@ struct gigaelectronvolt : prefixed_unit {} struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/force.h b/src/include/units/physical/si/force.h index d093c11ea..07adced40 100644 --- a/src/include/units/physical/si/force.h +++ b/src/include/units/physical/si/force.h @@ -54,7 +54,7 @@ struct yottanewton : prefixed_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/frequency.h b/src/include/units/physical/si/frequency.h index c3ebdaf10..a0a5d1100 100644 --- a/src/include/units/physical/si/frequency.h +++ b/src/include/units/physical/si/frequency.h @@ -48,7 +48,7 @@ struct yottahertz : prefixed_unit {}; struct dim_frequency : physical::dim_frequency {}; -template +template using frequency = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/heat_capacity.h b/src/include/units/physical/si/heat_capacity.h index db7f414e3..8cf3fe140 100644 --- a/src/include/units/physical/si/heat_capacity.h +++ b/src/include/units/physical/si/heat_capacity.h @@ -39,13 +39,13 @@ struct dim_heat_capacity : physical::dim_heat_capacity {}; struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity {}; -template +template using heat_capacity = quantity; -template +template using specific_heat_capacity = quantity; -template +template using molar_heat_capacity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/inductance.h b/src/include/units/physical/si/inductance.h index 8a394df8c..794909eef 100644 --- a/src/include/units/physical/si/inductance.h +++ b/src/include/units/physical/si/inductance.h @@ -50,7 +50,7 @@ struct yottahenry : prefixed_unit {}; struct dim_inductance : physical::dim_inductance {}; -template +template using inductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index 2e5b433f0..71d4f4361 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -54,7 +54,7 @@ struct astronomical_unit : named_scaled_unit {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminance.h b/src/include/units/physical/si/luminance.h index 04634eb80..389a6c464 100644 --- a/src/include/units/physical/si/luminance.h +++ b/src/include/units/physical/si/luminance.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct candela_per_metre_sq : unit {}; struct dim_luminance : physical::dim_luminance {}; -template +template using luminance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminous_intensity.h b/src/include/units/physical/si/luminous_intensity.h index a736f3d9b..ac57c0a8c 100644 --- a/src/include/units/physical/si/luminous_intensity.h +++ b/src/include/units/physical/si/luminous_intensity.h @@ -52,7 +52,7 @@ struct yottacandela : prefixed_unit {}; struct dim_luminous_intensity : physical::dim_luminous_intensity {}; -template +template using luminous_intensity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_flux.h b/src/include/units/physical/si/magnetic_flux.h index ceb3d0793..deeb545a1 100644 --- a/src/include/units/physical/si/magnetic_flux.h +++ b/src/include/units/physical/si/magnetic_flux.h @@ -50,7 +50,7 @@ struct yottaweber : prefixed_unit {}; struct dim_magnetic_flux : physical::dim_magnetic_flux {}; -template +template using magnetic_flux = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_induction.h b/src/include/units/physical/si/magnetic_induction.h index 80eeb18ee..5d11e6139 100644 --- a/src/include/units/physical/si/magnetic_induction.h +++ b/src/include/units/physical/si/magnetic_induction.h @@ -54,7 +54,7 @@ struct gauss : named_scaled_unit, tesla> {} struct dim_magnetic_induction : physical::dim_magnetic_induction {}; -template +template using magnetic_induction = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index a78d5caa9..5efd813f8 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -76,7 +76,7 @@ struct dalton : named_scaled_unit {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/molar_energy.h b/src/include/units/physical/si/molar_energy.h index dd06960b1..88323b96e 100644 --- a/src/include/units/physical/si/molar_energy.h +++ b/src/include/units/physical/si/molar_energy.h @@ -34,7 +34,7 @@ struct joule_per_mole : unit {}; struct dim_molar_energy : physical::dim_molar_energy {}; -template +template using molar_energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h index a0146f08c..3266eb07e 100644 --- a/src/include/units/physical/si/momentum.h +++ b/src/include/units/physical/si/momentum.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct kilogram_metre_per_second : unit {}; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permeability.h b/src/include/units/physical/si/permeability.h index 449794655..4930ace53 100644 --- a/src/include/units/physical/si/permeability.h +++ b/src/include/units/physical/si/permeability.h @@ -33,7 +33,7 @@ struct henry_per_metre : unit {}; struct dim_permeability : physical::dim_permeability {}; -template +template using permeability = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permittivity.h b/src/include/units/physical/si/permittivity.h index daf03c6a8..40f69cf71 100644 --- a/src/include/units/physical/si/permittivity.h +++ b/src/include/units/physical/si/permittivity.h @@ -33,7 +33,7 @@ struct farad_per_metre : unit {}; struct dim_permittivity : physical::dim_permittivity {}; -template +template using permittivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/power.h b/src/include/units/physical/si/power.h index c678e1d80..91c565d03 100644 --- a/src/include/units/physical/si/power.h +++ b/src/include/units/physical/si/power.h @@ -49,7 +49,7 @@ struct yottawatt : prefixed_unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index 90125eb6e..53ed1eff8 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -54,7 +54,7 @@ struct yottapascal : prefixed_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/resistance.h b/src/include/units/physical/si/resistance.h index 45569e37a..b7d86dc50 100644 --- a/src/include/units/physical/si/resistance.h +++ b/src/include/units/physical/si/resistance.h @@ -50,7 +50,7 @@ struct yottaohm : prefixed_unit {}; struct dim_resistance : physical::dim_resistance {}; -template +template using resistance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/speed.h b/src/include/units/physical/si/speed.h index 8d13a8554..2f4210187 100644 --- a/src/include/units/physical/si/speed.h +++ b/src/include/units/physical/si/speed.h @@ -34,7 +34,7 @@ struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/substance.h b/src/include/units/physical/si/substance.h index b58451b2b..5e9dd5e7a 100644 --- a/src/include/units/physical/si/substance.h +++ b/src/include/units/physical/si/substance.h @@ -32,7 +32,7 @@ struct mole : named_unit {}; struct dim_substance : physical::dim_substance {}; -template +template using substance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/surface_tension.h b/src/include/units/physical/si/surface_tension.h index 7fb04b2b7..b077f54f4 100644 --- a/src/include/units/physical/si/surface_tension.h +++ b/src/include/units/physical/si/surface_tension.h @@ -32,7 +32,7 @@ struct newton_per_metre : unit {}; struct dim_surface_tension : physical::dim_surface_tension {}; -template +template using surface_tension = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index 763704757..2b3b05573 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -31,7 +31,7 @@ struct kelvin : named_unit {}; struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature {}; -template +template using temperature = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/thermal_conductivity.h b/src/include/units/physical/si/thermal_conductivity.h index 9f54ca7ae..0a7a88f18 100644 --- a/src/include/units/physical/si/thermal_conductivity.h +++ b/src/include/units/physical/si/thermal_conductivity.h @@ -33,7 +33,7 @@ struct watt_per_metre_kelvin : unit {}; struct dim_thermal_conductivity : physical::dim_thermal_conductivity {}; -template +template using thermal_conductivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index 198a67522..273252f9c 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -43,7 +43,7 @@ struct day : named_scaled_unit, hour> {}; struct dim_time : physical::dim_time {}; -template +template using time = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/torque.h b/src/include/units/physical/si/torque.h index 4f18fae1a..6632a2d15 100644 --- a/src/include/units/physical/si/torque.h +++ b/src/include/units/physical/si/torque.h @@ -34,7 +34,7 @@ struct newton_metre : named_unit {}; struct dim_torque : physical::dim_torque {}; -template +template using torque = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index da48ec194..68dac06e4 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -54,7 +54,7 @@ struct yottavolt : prefixed_unit {}; struct dim_voltage : physical::dim_voltage {}; -template +template using voltage = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/volume.h b/src/include/units/physical/si/volume.h index 047088e21..00e43ad86 100644 --- a/src/include/units/physical/si/volume.h +++ b/src/include/units/physical/si/volume.h @@ -74,7 +74,7 @@ struct exalitre : prefixed_unit {}; struct zettalitre : prefixed_alias_unit {}; struct yottalitre : prefixed_unit {}; -template +template using volume = quantity; inline namespace literals { diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index 17e19cf9d..e08e1828a 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -60,7 +60,7 @@ concept safe_divisible = // exposition only * @tparam U a measurement unit of the quantity * @tparam Rep a type to be used to represent values of a quantity */ -template U, Value Rep = double> +template U, NumericValue Rep = double> class quantity { Rep value_{}; @@ -73,7 +73,7 @@ class quantity { quantity(const quantity&) = default; quantity(quantity&&) = default; - template + template requires detail::safe_convertible constexpr explicit quantity(const Val& v) : value_{static_cast(v)} {} @@ -200,12 +200,12 @@ class quantity { return *this; } - template + template constexpr quantity& operator%=(const Val& rhs) requires (!treat_as_floating_point) && (!treat_as_floating_point) && requires(T v1, Val v2) { { v1 %= v2 } -> SAME_AS(T&); } - // requires(rep v1, Value v2) { { v1 %= v2 } -> SAME_AS(rep&); } // TODO gated by gcc-9 (fixed in gcc-10) + // requires(rep v1, NumericValue v2) { { v1 %= v2 } -> SAME_AS(rep&); } // TODO gated by gcc-9 (fixed in gcc-10) { value_ %= rhs; return *this; @@ -322,7 +322,7 @@ template return ret(ret(lhs).count() - ret(rhs).count()); } -template +template [[nodiscard]] constexpr Quantity AUTO operator*(const quantity& q, const Val& v) requires std::regular_invocable, Rep, Val> { @@ -331,7 +331,7 @@ template return ret(q.count() * v); } -template +template [[nodiscard]] constexpr Quantity AUTO operator*(const Val& v, const quantity& q) requires std::regular_invocable, Val, Rep> { @@ -339,7 +339,7 @@ template } template -[[nodiscard]] constexpr Value AUTO operator*(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr NumericValue AUTO operator*(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim> { @@ -366,7 +366,7 @@ template +template [[nodiscard]] constexpr Quantity AUTO operator/(const Val& v, const quantity& q) requires std::regular_invocable, Val, Rep> { @@ -380,7 +380,7 @@ template return ret(v / q.count()); } -template +template [[nodiscard]] constexpr Quantity AUTO operator/(const quantity& q, const Val& v) requires std::regular_invocable, Rep, Val> { @@ -392,7 +392,7 @@ template } template -[[nodiscard]] constexpr Value AUTO operator/(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr NumericValue AUTO operator/(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim { @@ -419,7 +419,7 @@ template +template [[nodiscard]] constexpr Quantity AUTO operator%(const quantity& q, const Val& v) requires (!treat_as_floating_point) && (!treat_as_floating_point) && diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index 004cf8843..4f56f9e8a 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -386,7 +386,7 @@ template * * @tparam ToRep a representation type to use for a target quantity */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) { return quantity_cast>(q); diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index 005184d6a..a35aff35f 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -85,7 +85,7 @@ using impl_impl = impl_constructible_impl_convertible; static_assert(std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::Value>); +static_assert(units::NumericValue>); template struct expl_constructible_impl_convertible : scalar_ops> { @@ -100,7 +100,7 @@ using expl_impl = expl_constructible_impl_convertible; static_assert(!std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::Value>); +static_assert(units::NumericValue>); template struct impl_constructible_expl_convertible : scalar_ops> { @@ -115,7 +115,7 @@ using impl_expl = impl_constructible_expl_convertible; static_assert(std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::Value>); +static_assert(units::NumericValue>); template struct expl_constructible_expl_convertible : scalar_ops> { @@ -130,7 +130,7 @@ using expl_expl = expl_constructible_expl_convertible; static_assert(!std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::Value>); +static_assert(units::NumericValue>); } // namespace @@ -169,7 +169,7 @@ using namespace units::physical::si; // constructors -// Quantity from Value +// Quantity from NumericValue // int <- int static_assert(length(expl_impl(1)).count() == 1); // static_assert(length(impl_expl(1)).count() == 1); // should not compile (not convertible) diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index 016fa1e2e..2e04988b5 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -35,14 +35,14 @@ using namespace units::physical::si; struct sq_volt_per_hertz : unit {}; struct dim_power_spectral_density : derived_dimension, units::exp> {}; -template +template using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; struct dim_amplitude_spectral_density : derived_dimension, units::exp> {}; -template +template using amplitude_spectral_density = quantity; } From 02cd28f4cdbd63b493a17206a04d6139125f0fbb Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 7 Jun 2020 12:52:54 +0100 Subject: [PATCH 3/6] rename concepts 2 --- example/linear_algebra.cpp | 6 +- src/include/units/base_dimension.h | 10 +- src/include/units/bits/base_units_ratio.h | 2 +- src/include/units/bits/deduced_symbol_text.h | 2 +- src/include/units/bits/deduced_unit.h | 24 ++--- .../units/bits/derived_dimension_base.h | 6 +- src/include/units/bits/dim_consolidate.h | 2 +- src/include/units/bits/dim_unpack.h | 8 +- src/include/units/bits/dimension_op.h | 52 +++++----- src/include/units/bits/to_string.h | 8 +- src/include/units/concepts.h | 54 +++++------ src/include/units/data/bitrate.h | 2 +- src/include/units/data/information.h | 2 +- src/include/units/derived_dimension.h | 4 +- src/include/units/exp.h | 12 +-- src/include/units/format.h | 16 ++-- src/include/units/math.h | 2 +- src/include/units/physical/cgs/acceleration.h | 2 +- src/include/units/physical/cgs/area.h | 2 +- src/include/units/physical/cgs/energy.h | 2 +- src/include/units/physical/cgs/force.h | 2 +- src/include/units/physical/cgs/length.h | 2 +- src/include/units/physical/cgs/mass.h | 2 +- src/include/units/physical/cgs/power.h | 2 +- src/include/units/physical/cgs/pressure.h | 2 +- src/include/units/physical/cgs/speed.h | 2 +- src/include/units/physical/dimensions.h | 94 +++++++++---------- .../units/physical/natural/dimensions.h | 16 ++-- src/include/units/physical/si/absorbed_dose.h | 2 +- src/include/units/physical/si/acceleration.h | 2 +- src/include/units/physical/si/angle.h | 2 +- src/include/units/physical/si/area.h | 2 +- src/include/units/physical/si/capacitance.h | 2 +- .../units/physical/si/catalytic_activity.h | 2 +- .../units/physical/si/charge_density.h | 4 +- src/include/units/physical/si/concentration.h | 2 +- src/include/units/physical/si/conductance.h | 2 +- src/include/units/physical/si/current.h | 2 +- .../units/physical/si/current_density.h | 2 +- src/include/units/physical/si/density.h | 2 +- .../units/physical/si/dynamic_viscosity.h | 2 +- .../units/physical/si/electric_charge.h | 2 +- .../physical/si/electric_field_strength.h | 2 +- src/include/units/physical/si/energy.h | 2 +- src/include/units/physical/si/force.h | 2 +- src/include/units/physical/si/frequency.h | 2 +- src/include/units/physical/si/heat_capacity.h | 6 +- src/include/units/physical/si/inductance.h | 2 +- src/include/units/physical/si/length.h | 2 +- src/include/units/physical/si/luminance.h | 2 +- .../units/physical/si/luminous_intensity.h | 2 +- src/include/units/physical/si/magnetic_flux.h | 2 +- .../units/physical/si/magnetic_induction.h | 2 +- src/include/units/physical/si/mass.h | 2 +- src/include/units/physical/si/molar_energy.h | 2 +- src/include/units/physical/si/momentum.h | 2 +- src/include/units/physical/si/permeability.h | 2 +- src/include/units/physical/si/permittivity.h | 2 +- src/include/units/physical/si/power.h | 2 +- src/include/units/physical/si/pressure.h | 2 +- src/include/units/physical/si/resistance.h | 2 +- src/include/units/physical/si/speed.h | 2 +- src/include/units/physical/si/substance.h | 2 +- .../units/physical/si/surface_tension.h | 2 +- src/include/units/physical/si/temperature.h | 2 +- .../units/physical/si/thermal_conductivity.h | 2 +- src/include/units/physical/si/time.h | 2 +- src/include/units/physical/si/torque.h | 2 +- src/include/units/physical/si/voltage.h | 2 +- src/include/units/physical/si/volume.h | 2 +- src/include/units/prefix.h | 6 +- src/include/units/quantity.h | 2 +- src/include/units/quantity_cast.h | 10 +- src/include/units/ratio.h | 22 ++--- src/include/units/unit.h | 26 ++--- test/unit_test/static/custom_unit_test.cpp | 4 +- test/unit_test/static/dimension_op_test.cpp | 2 +- test/unit_test/static/ratio_test.cpp | 2 +- 78 files changed, 252 insertions(+), 252 deletions(-) diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 2024e51d9..94ab3e85d 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -201,10 +201,10 @@ void matrix_of_quantity_tests() matrix_of_quantity_divide_by_scalar(); } -template +template using length_v = si::length>; -template +template using force_v = si::force>; void quantity_of_vector_add() @@ -274,7 +274,7 @@ void quantity_of_vector_tests() quantity_of_vector_divide_by_scalar(); } -template +template using length_m = si::length>; void quantity_of_matrix_add() diff --git a/src/include/units/base_dimension.h b/src/include/units/base_dimension.h index 579000282..90d916ddd 100644 --- a/src/include/units/base_dimension.h +++ b/src/include/units/base_dimension.h @@ -38,16 +38,16 @@ 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 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 + * Pair of Symbol and in_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 in_exponent of a in_derived_dimension * (in case of zero the dimension will be simplified and removed from further analysis of current expresion). In case - * the Symbol 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 in_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 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_base_dimension when fixed @@ -56,7 +56,7 @@ struct base_dimension { }; // base_dimension_less -template +template struct base_dimension_less : std::bool_constant<(D1::symbol < D2::symbol) || (D1::symbol == D2::symbol && D1::base_unit::symbol < D1::base_unit::symbol)> { diff --git a/src/include/units/bits/base_units_ratio.h b/src/include/units/bits/base_units_ratio.h index 1d6fbdcd9..ba061bed0 100644 --- a/src/include/units/bits/base_units_ratio.h +++ b/src/include/units/bits/base_units_ratio.h @@ -28,7 +28,7 @@ namespace units::detail { -template +template requires (E::den == 1 || E::den == 2) // TODO provide support for any den struct exp_ratio { using base_ratio = E::dimension::base_unit::ratio; diff --git a/src/include/units/bits/deduced_symbol_text.h b/src/include/units/bits/deduced_symbol_text.h index 38b071c06..636b58557 100644 --- a/src/include/units/bits/deduced_symbol_text.h +++ b/src/include/units/bits/deduced_symbol_text.h @@ -86,7 +86,7 @@ constexpr auto deduced_symbol_text(exp_list, std::index_sequence return (exp_text() + ...); } -template +template constexpr auto deduced_symbol_text() { return deduced_symbol_text(typename Dim::recipe(), std::index_sequence_for()); diff --git a/src/include/units/bits/deduced_unit.h b/src/include/units/bits/deduced_unit.h index e8832da6b..6e5f45c0d 100644 --- a/src/include/units/bits/deduced_unit.h +++ b/src/include/units/bits/deduced_unit.h @@ -27,45 +27,45 @@ namespace units::detail { // same_scaled_units -template +template inline constexpr bool same_scaled_units = false; -template +template inline constexpr bool same_scaled_units, Us...> = (UnitOf && ...); // deduced_unit -template +template struct ratio_op; -template -struct ratio_op { +template +struct ratio_op { using ratio = Result; }; -template +template struct ratio_op { using calc_ratio = - conditional<(UnitExpNum * UnitExpDen > 0), ratio_multiply, ratio_divide>; + conditional<(UnitExpNum * UnitExpDen > 0), ratio_multiply, ratio_divide>; static constexpr int value = (UnitExpNum * UnitExpDen > 0) ? (UnitExpNum - UnitExpDen) : (UnitExpNum + UnitExpDen); - using ratio = ratio_op::ratio; + using ratio = ratio_op::ratio; }; -template +template struct derived_ratio; -template +template struct derived_ratio, Us...> { using ratio = ::units::ratio<1>; }; -template +template struct derived_ratio, U, URest...> { using rest_ratio = derived_ratio, URest...>::ratio; using unit_ratio = ratio_op::ratio; using ratio = ratio_divide::ratio>; }; -template +template using deduced_unit = scaled_unit::ratio, typename D::coherent_unit::reference>; diff --git a/src/include/units/bits/derived_dimension_base.h b/src/include/units/bits/derived_dimension_base.h index 71fdcc1b3..e0b80c600 100644 --- a/src/include/units/bits/derived_dimension_base.h +++ b/src/include/units/bits/derived_dimension_base.h @@ -44,8 +44,8 @@ namespace units::detail { * @tparam E a first exponent of a derived dimension * @tparam ERest zero or more following exponents of a derived dimension */ -template - requires (BaseDimension && ... && BaseDimension) +template + requires (in_base_dimension && ... && in_base_dimension) struct derived_dimension_base : downcast_base> { using exponents = exp_list; }; @@ -53,7 +53,7 @@ struct derived_dimension_base : downcast_base struct to_derived_dimension_base; -template +template struct to_derived_dimension_base> { using type = derived_dimension_base; }; diff --git a/src/include/units/bits/dim_consolidate.h b/src/include/units/bits/dim_consolidate.h index aba1a706e..aab1c840b 100644 --- a/src/include/units/bits/dim_consolidate.h +++ b/src/include/units/bits/dim_consolidate.h @@ -54,7 +54,7 @@ struct dim_consolidate> { using type = type_list_push_front>::type, E1>; }; -template +template struct dim_consolidate, exp, ERest...>> { // TODO: we have ration_add now, but dim_consolidate etc, now need to cope with our new ratio using r1 = std::ratio; diff --git a/src/include/units/bits/dim_unpack.h b/src/include/units/bits/dim_unpack.h index cdcf9bf44..986c4d925 100644 --- a/src/include/units/bits/dim_unpack.h +++ b/src/include/units/bits/dim_unpack.h @@ -33,7 +33,7 @@ namespace units::detail { * * @tparam Es Exponents of potentially derived dimensions */ -template +template struct dim_unpack; template<> @@ -41,17 +41,17 @@ struct dim_unpack<> { using type = exp_list<>; }; -template +template struct dim_unpack, ERest...> { using type = type_list_push_front::type, exp>; }; -template +template struct dim_unpack, ERest...> { using type = dim_unpack, Num, Den>, ERest...>::type; }; -template +template struct dim_unpack, Num, Den>, ERest...> { using type = type_list_push_front::type, exp_multiply...>; }; diff --git a/src/include/units/bits/dimension_op.h b/src/include/units/bits/dimension_op.h index f0f54ac1c..6180ec9e3 100644 --- a/src/include/units/bits/dimension_op.h +++ b/src/include/units/bits/dimension_op.h @@ -33,27 +33,27 @@ namespace detail { template struct equivalent_dim_impl : std::false_type {}; -template +template struct equivalent_base_dim : std::conjunction, same_unit_reference> {}; -template +template struct equivalent_dim_impl : std::disjunction, equivalent_base_dim> {}; -template +template struct equivalent_exp : std::false_type {}; -template +template struct equivalent_exp, exp> : equivalent_dim_impl {}; -template +template struct equivalent_derived_dim : std::false_type {}; template requires (sizeof...(Es1) == sizeof...(Es2)) struct equivalent_derived_dim, derived_dimension_base> : std::conjunction...> {}; -template +template struct equivalent_dim_impl : std::disjunction, equivalent_derived_dim, downcast_base_t>> {}; } // namespace detail @@ -71,14 +71,14 @@ inline constexpr bool equivalent_dim = detail::equivalent_dim_impl::valu * @tparam E the list of exponents of ingredient dimensions * @tparam ERest the list of exponents of ingredient dimensions */ -template +template struct unknown_dimension : derived_dimension, scaled_unit, unknown_coherent_unit>, E, ERest...> { using coherent_unit = scaled_unit, unknown_coherent_unit>; }; namespace detail { -template +template struct check_unknown { using type = D; }; @@ -92,12 +92,12 @@ struct check_unknown> { template struct downcast_dimension_impl; -template +template struct downcast_dimension_impl { using type = D; }; -template +template struct downcast_dimension_impl { using type = check_unknown>::type; }; @@ -113,12 +113,12 @@ namespace detail { template struct dim_invert_impl; -template +template struct dim_invert_impl { using type = downcast_dimension>>; }; -template +template struct dim_invert_impl>> { using type = D; }; @@ -128,7 +128,7 @@ struct dim_invert_impl> { using type = downcast_dimension...>>; }; -template +template struct dim_invert_impl : dim_invert_impl> { }; @@ -143,12 +143,12 @@ namespace detail { template struct to_dimension; -template +template struct to_dimension> { using type = derived_dimension_base; }; -template +template struct to_dimension>> { using type = D; }; @@ -168,22 +168,22 @@ using merge_dimension = to_dimension struct dimension_multiply_impl; -template +template struct dimension_multiply_impl { using type = downcast_dimension>, derived_dimension_base>>>; }; -template +template struct dimension_multiply_impl { using type = downcast_dimension>, typename D2::downcast_base_type>>; }; -template +template struct dimension_multiply_impl { using type = dimension_multiply_impl::type; }; -template +template struct dimension_multiply_impl { using type = downcast_dimension>; }; @@ -202,17 +202,17 @@ namespace detail { template struct dimension_sqrt_impl; -template +template struct dimension_sqrt_impl { using type = downcast_dimension>>; }; -template +template struct dimension_sqrt_impl>> { using type = D; }; -template +template struct dimension_sqrt_impl { using type = dimension_sqrt_impl::type; }; @@ -233,22 +233,22 @@ namespace detail { template struct dimension_pow_impl; -template +template struct dimension_pow_impl { using type = downcast_dimension>>; }; -template +template struct dimension_pow_impl { using type = D; }; -template +template struct dimension_pow_impl>, N> { using type = D; }; -template +template struct dimension_pow_impl { using type = dimension_pow_impl, N>::type; }; diff --git a/src/include/units/bits/to_string.h b/src/include/units/bits/to_string.h index 0c9f49882..937995858 100644 --- a/src/include/units/bits/to_string.h +++ b/src/include/units/bits/to_string.h @@ -107,10 +107,10 @@ constexpr auto derived_dimension_unit_text(exp_list list) return derived_dimension_unit_text(list, std::index_sequence_for()); } -template +template constexpr auto exp_list_with_named_units(exp_list); -template +template constexpr auto exp_list_with_named_units(Exp) { using dim = Exp::dimension; @@ -123,7 +123,7 @@ constexpr auto exp_list_with_named_units(Exp) } } -template +template constexpr auto exp_list_with_named_units(exp_list) { return type_list_join(); @@ -140,7 +140,7 @@ constexpr auto derived_dimension_unit_text() template concept has_symbol = requires{ T::symbol; }; -template +template constexpr auto unit_text() { if constexpr(has_symbol) { diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 271f915f2..e592cc788 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -29,7 +29,7 @@ namespace units { -// PrefixFamily +// in_prefix_family struct prefix_family; /** @@ -38,9 +38,9 @@ struct prefix_family; * Satisfied by all types derived from `prefix_family` */ template -concept PrefixFamily = std::derived_from; +concept in_prefix_family = std::derived_from; -// Prefix +// in_prefix // TODO gcc:92150 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92150 // namespace detail { @@ -48,8 +48,8 @@ concept PrefixFamily = std::derived_from; // template // inline constexpr bool is_prefix = false; -// template -// inline constexpr bool is_prefix> = true; +// template +// inline constexpr bool is_prefix> = true; // } // namespace detail @@ -59,8 +59,8 @@ concept PrefixFamily = std::derived_from; * Satisfied by all instantiations of `prefix`. */ template -// concept Prefix = detail::is_prefix; -concept Prefix = true; +// concept in_prefix = detail::is_prefix; +concept in_prefix = true; namespace detail { @@ -76,18 +76,18 @@ inline constexpr bool is_ratio = false; * Satisfied by all instantiations of `ratio`. */ template -concept Ratio = detail::is_ratio; +concept in_ratio = detail::is_ratio; /** * @brief A concept matching unit's ratio * - * Satisfied by all types that satisfy `Ratio` and for which `R::num > 0` and `R::den > 0` + * Satisfied by all types that satisfy `in_ratio` and for which `R::num > 0` and `R::den > 0` */ template -concept UnitRatio = Ratio && R::num > 0 && R::den > 0; // double negatives not allowed +concept in_unit_ratio = in_ratio && R::num > 0 && R::den > 0; // double negatives not allowed -// Unit -template +// in_unit +template struct scaled_unit; /** @@ -96,9 +96,9 @@ struct scaled_unit; * Satisfied by all unit types derived from the instantiation of :class:`scaled_unit`. */ template -concept Unit = is_derived_from_instantiation; +concept in_unit = is_derived_from_instantiation; -template +template requires U::is_named struct base_dimension; @@ -127,9 +127,9 @@ inline constexpr bool is_base_dimension> = true; * Satisfied by all dimension types derived from the instantiation of `base_dimension`. */ template -concept BaseDimension = detail::is_base_dimension; +concept in_base_dimension = detail::is_base_dimension; -// Exponent +// in_exponent namespace detail { template @@ -143,13 +143,13 @@ inline constexpr bool is_exp = false; * Satisfied by all instantiations of :class:`exp`. */ template -concept Exponent = detail::is_exp; +concept in_exponent = detail::is_exp; -// DerivedDimension +// in_derived_dimension namespace detail { -template - requires (BaseDimension && ... && BaseDimension) +template + requires (in_base_dimension && ... && in_base_dimension) struct derived_dimension_base; } // namespace detail @@ -160,16 +160,16 @@ struct derived_dimension_base; * Satisfied by all dimension types derived from the instantiation of `detail::derived_dimension_base`. */ template -concept DerivedDimension = is_instantiation, detail::derived_dimension_base>; +concept in_derived_dimension = is_instantiation, detail::derived_dimension_base>; // Dimension /** * @brief A concept matching all dimensions in the library. * - * Satisfied by all dimension types for which either `BaseDimension` or `DerivedDimension` is `true`. + * Satisfied by all dimension types for which either `in_base_dimension` or `in_derived_dimension` is `true`. */ template -concept Dimension = BaseDimension || DerivedDimension; +concept Dimension = in_base_dimension || in_derived_dimension; // UnitOf namespace detail { @@ -177,12 +177,12 @@ namespace detail { template struct dimension_unit_impl; -template +template struct dimension_unit_impl { using type = D::base_unit; }; -template +template struct dimension_unit_impl { using type = D::coherent_unit; }; @@ -203,7 +203,7 @@ using dimension_unit = detail::dimension_unit_impl::type; /** * @brief A concept matching only units of a specified dimension. * - * Satisfied by all unit types that satisfy `Unit`, `Dimension`, and for which + * Satisfied by all unit types that satisfy `in_unit`, `Dimension`, and for which * `U::reference` and @c dimension_unit::reference denote the same unit type. * * @tparam U Type to verify. @@ -211,7 +211,7 @@ using dimension_unit = detail::dimension_unit_impl::type; */ template concept UnitOf = - Unit && + in_unit && Dimension && std::same_as::reference>; diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index cdf9483cb..5bef46801 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -41,7 +41,7 @@ struct pebibit_per_second : deduced_unit concept Bitrate = QuantityOf; -template +template using bitrate = quantity; inline namespace literals { diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index d2c65df86..cd1f84571 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -48,7 +48,7 @@ struct dim_information : base_dimension<"information", bit> {}; template concept Information = QuantityOf; -template +template using information = quantity; inline namespace literals { diff --git a/src/include/units/derived_dimension.h b/src/include/units/derived_dimension.h index cdfdf31ff..e77bce60e 100644 --- a/src/include/units/derived_dimension.h +++ b/src/include/units/derived_dimension.h @@ -45,7 +45,7 @@ namespace detail { * 3. Consolidate contiguous range of exponents of the same base dimensions to a one (or possibly zero) exponent for * this base dimension. */ -template +template using make_dimension = to_derived_dimension_base::type, exp_less>>::type>::type; } // namespace detail @@ -78,7 +78,7 @@ using make_dimension = to_derived_dimension_base +template struct derived_dimension : downcast_child> { using recipe = exp_list; using coherent_unit = U; diff --git a/src/include/units/exp.h b/src/include/units/exp.h index 731187aa2..82e43bd31 100644 --- a/src/include/units/exp.h +++ b/src/include/units/exp.h @@ -50,8 +50,8 @@ inline constexpr bool is_exp> = true; } // namespace detail // exp_less -template - requires BaseDimension && BaseDimension +template + requires in_base_dimension && in_base_dimension struct exp_less : base_dimension_less {}; // exp_invert @@ -62,13 +62,13 @@ constexpr exp exp_invert_impl(exp); } // namespace detail -template +template using exp_invert = decltype(detail::exp_invert_impl(E())); // exp_multiply namespace detail { -template +template struct exp_multiply_impl { using r1 = ratio; using r2 = ratio; @@ -78,10 +78,10 @@ struct exp_multiply_impl { } // namespace detail -template +template using exp_multiply = detail::exp_multiply_impl::type; -template +template struct exp_list {}; } // namespace units diff --git a/src/include/units/format.h b/src/include/units/format.h index 8e2f068b9..bba47cf43 100644 --- a/src/include/units/format.h +++ b/src/include/units/format.h @@ -233,7 +233,7 @@ namespace units { return format_to(out, fmt::to_string(buffer), val); } - template + template struct units_formatter { OutputIt out; Rep val; @@ -242,7 +242,7 @@ namespace units { unit_format_specs const & unit_specs; explicit units_formatter( - OutputIt o, quantity q, + OutputIt o, quantity q, global_format_specs const & gspecs, rep_format_specs const & rspecs, unit_format_specs const & uspecs ): @@ -263,7 +263,7 @@ namespace units { void on_quantity_unit([[maybe_unused]] const CharT) { - auto txt = unit_text(); + auto txt = unit_text(); auto txt_c_str = unit_specs.modifier == 'A' ? txt.ascii().c_str() : txt.standard().c_str(); format_to(out, "{}", txt_c_str); } @@ -273,10 +273,10 @@ namespace units { } // namespace units -template -struct fmt::formatter, CharT> { +template +struct fmt::formatter, CharT> { private: - using quantity = units::quantity; + using quantity = units::quantity; using iterator = fmt::basic_format_parse_context::iterator; using arg_ref_type = fmt::internal::arg_ref; @@ -414,7 +414,7 @@ struct fmt::formatter, CharT> { } template - auto format(const units::quantity& q, FormatContext& ctx) + auto format(const units::quantity& q, FormatContext& ctx) { auto begin = format_str.begin(), end = format_str.end(); @@ -461,7 +461,7 @@ struct fmt::formatter, CharT> { if(begin == end || *begin == '}') { // default format should print value followed by the unit separated with 1 space to_quantity_buffer = units::detail::format_units_quantity_value(to_quantity_buffer, q.count(), rep_specs); - constexpr auto symbol = units::detail::unit_text(); + constexpr auto symbol = units::detail::unit_text(); if(symbol.standard().size()) { *to_quantity_buffer++ = CharT(' '); format_to(to_quantity_buffer, "{}", symbol.standard().c_str()); diff --git a/src/include/units/math.h b/src/include/units/math.h index ae2e33974..d42bac4a9 100644 --- a/src/include/units/math.h +++ b/src/include/units/math.h @@ -34,7 +34,7 @@ namespace units { * * Both the quantity value and its dimension are the base of the operation. * - * @tparam N Exponent + * @tparam N in_exponent * @param q Quantity being the base of the operation * @return Quantity The result of computation */ diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index a0cc45893..9a421fa22 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::cgs { struct gal : named_unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/area.h b/src/include/units/physical/cgs/area.h index 4aaf7fed1..2618acce7 100644 --- a/src/include/units/physical/cgs/area.h +++ b/src/include/units/physical/cgs/area.h @@ -33,7 +33,7 @@ using si::square_centimetre; struct dim_area : physical::dim_area {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/energy.h b/src/include/units/physical/cgs/energy.h index 0dc284547..5d8ee4ae3 100644 --- a/src/include/units/physical/cgs/energy.h +++ b/src/include/units/physical/cgs/energy.h @@ -33,7 +33,7 @@ struct erg : named_unit {}; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index 8720641e9..5f35dee61 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -34,7 +34,7 @@ struct dyne : named_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index 75639f76e..0c483596f 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -32,7 +32,7 @@ using si::centimetre; struct dim_length : physical::dim_length {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/mass.h b/src/include/units/physical/cgs/mass.h index 6ef55d4a4..d1b34a848 100644 --- a/src/include/units/physical/cgs/mass.h +++ b/src/include/units/physical/cgs/mass.h @@ -32,7 +32,7 @@ using si::gram; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index a37295252..5d2447b1e 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -33,7 +33,7 @@ struct erg_per_second : unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/pressure.h b/src/include/units/physical/cgs/pressure.h index a7c956b13..39930b3e0 100644 --- a/src/include/units/physical/cgs/pressure.h +++ b/src/include/units/physical/cgs/pressure.h @@ -34,7 +34,7 @@ struct barye : named_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/speed.h b/src/include/units/physical/cgs/speed.h index 7bbce4398..f22404a62 100644 --- a/src/include/units/physical/cgs/speed.h +++ b/src/include/units/physical/cgs/speed.h @@ -32,7 +32,7 @@ namespace units::physical::cgs { struct centimetre_per_second : unit {}; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index 10a10a322..ecd2c4401 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -37,149 +37,149 @@ concept QuantityOf = Quantity && is_derived_from_instantiation +template struct dim_length : base_dimension<"L", U> {}; -template +template struct dim_mass : base_dimension<"M", U> {}; -template +template struct dim_time : base_dimension<"T", U> {}; -template +template struct dim_electric_current : base_dimension<"I", U> {}; -template +template struct dim_thermodynamic_temperature : base_dimension<"Θ", U> {}; -template +template struct dim_substance : base_dimension<"N", U> {}; -template +template struct dim_luminous_intensity : base_dimension<"J", U> {}; -template +template struct dim_angle : base_dimension<"A", U> {}; // ------------------------ derived dimensions ----------------------------- -template T> +template T> struct dim_frequency : derived_dimension> {}; -template L> +template L> struct dim_area : derived_dimension> {}; -template L> +template L> struct dim_volume : derived_dimension> {}; -template L, DimensionOf T> +template L, DimensionOf T> struct dim_speed : derived_dimension, exp> {}; -template L, DimensionOf T> +template L, DimensionOf T> struct dim_acceleration : derived_dimension, exp> {}; -template M, DimensionOf A> +template M, DimensionOf A> struct dim_force : derived_dimension, exp> {}; -template M, DimensionOf V> +template M, DimensionOf V> struct dim_momentum : derived_dimension, exp> {}; -template F, DimensionOf L> +template F, DimensionOf L> struct dim_energy : derived_dimension, exp> {}; -template E, DimensionOf A> +template E, DimensionOf A> struct dim_torque : derived_dimension, exp> {}; -template M, DimensionOf L> +template M, DimensionOf L> struct dim_density : derived_dimension, exp> {}; -template E, DimensionOf T> +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 V, DimensionOf C> +template V, DimensionOf C> struct dim_resistance : derived_dimension, exp> {}; -template T, DimensionOf C> +template T, DimensionOf C> struct dim_electric_charge : derived_dimension, exp> {}; -template C, DimensionOf V> +template C, DimensionOf V> struct dim_capacitance : derived_dimension, exp> {}; -template F, DimensionOf L> +template F, DimensionOf L> struct dim_surface_tension : derived_dimension, exp> {}; -template F, DimensionOf A> +template F, DimensionOf A> struct dim_pressure : derived_dimension, exp> {}; -template V, DimensionOf T, DimensionOf L> +template V, DimensionOf T, DimensionOf L> struct dim_magnetic_induction : derived_dimension, exp, exp> {}; -template B, DimensionOf A> +template B, DimensionOf A> struct dim_magnetic_flux : derived_dimension, exp> {}; -template F, DimensionOf I> +template F, DimensionOf I> struct dim_inductance : derived_dimension, exp> {}; -template R> +template R> struct dim_conductance : derived_dimension> {}; // TODO Add when downcasting issue is solved -// template T> +// template T> // struct dim_radioactivity : derived_dimension> {}; -template T, DimensionOf M> +template T, DimensionOf M> struct dim_catalytic_activity : derived_dimension, exp> {}; -template E, DimensionOf M> +template E, DimensionOf M> struct dim_absorbed_dose : derived_dimension, exp> {}; -template I, DimensionOf L> +template I, DimensionOf L> struct dim_current_density : derived_dimension, exp> {}; -template M, DimensionOf L> +template M, DimensionOf L> struct dim_concentration : derived_dimension, exp> {}; -template I, DimensionOf L> +template I, DimensionOf L> struct dim_luminance : derived_dimension, exp> {}; -template P, DimensionOf T> +template P, DimensionOf T> struct dim_dynamic_viscosity : derived_dimension, exp> {}; -template E, DimensionOf T> +template E, DimensionOf T> struct dim_heat_capacity : derived_dimension, exp> {}; -template C, DimensionOf M> +template C, DimensionOf M> struct dim_specific_heat_capacity : derived_dimension, exp> {}; -template C, DimensionOf M> +template C, DimensionOf M> struct dim_molar_heat_capacity : derived_dimension, exp> {}; -template P, DimensionOf L, DimensionOf T> +template P, DimensionOf L, DimensionOf T> struct dim_thermal_conductivity : derived_dimension, exp, exp> {}; // TODO Add when downcasting issue is solved -// template E, DimensionOf L> +// template E, DimensionOf L> // struct dim_energy_density : derived_dimension, exp> {}; -template V, DimensionOf L> +template V, DimensionOf L> struct dim_electric_field_strength : derived_dimension, exp> {}; -template Q, DimensionOf L> +template Q, DimensionOf L> struct dim_charge_density : derived_dimension, exp> {}; -template Q, DimensionOf L> +template Q, DimensionOf L> struct dim_surface_charge_density : derived_dimension, exp> {}; -template C, DimensionOf L> +template C, DimensionOf L> struct dim_permittivity : derived_dimension, exp> {}; -template H, DimensionOf L> +template H, DimensionOf L> struct dim_permeability : derived_dimension, exp> {}; -template E, DimensionOf M> +template E, DimensionOf M> struct dim_molar_energy : derived_dimension, exp> {}; template diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index fac8f26ce..b97ae2e75 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -29,35 +29,35 @@ namespace units::physical::natural { struct dim_length : physical::dim_length {}; -template +template using length = quantity; struct dim_time : physical::dim_time {}; -template +template using time = quantity; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; struct dim_force : physical::dim_force {}; -template +template using force = quantity; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; // Typical UDLs will not work here as the same units are reused by many quantities. diff --git a/src/include/units/physical/si/absorbed_dose.h b/src/include/units/physical/si/absorbed_dose.h index 8b480bf53..4713416f3 100644 --- a/src/include/units/physical/si/absorbed_dose.h +++ b/src/include/units/physical/si/absorbed_dose.h @@ -54,7 +54,7 @@ struct yottagray : prefixed_unit {}; struct dim_absorbed_dose : physical::dim_absorbed_dose {}; -template +template using absorbed_dose = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index e3297088f..19ffd3278 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct metre_per_second_sq : unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/angle.h b/src/include/units/physical/si/angle.h index c021a7e9d..29d2d560c 100644 --- a/src/include/units/physical/si/angle.h +++ b/src/include/units/physical/si/angle.h @@ -32,7 +32,7 @@ struct radian : named_unit {}; struct dim_angle : physical::dim_angle {}; -template +template using angle = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index 71ef9364e..8eb0027a9 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -54,7 +54,7 @@ struct square_yottametre : deduced_unit struct hectare : alias_unit {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/capacitance.h b/src/include/units/physical/si/capacitance.h index 0a0637f86..dfb835882 100644 --- a/src/include/units/physical/si/capacitance.h +++ b/src/include/units/physical/si/capacitance.h @@ -54,7 +54,7 @@ struct yottafarad : prefixed_unit {}; struct dim_capacitance : physical::dim_capacitance {}; -template +template using capacitance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/catalytic_activity.h b/src/include/units/physical/si/catalytic_activity.h index 952abfb43..3aa7b186f 100644 --- a/src/include/units/physical/si/catalytic_activity.h +++ b/src/include/units/physical/si/catalytic_activity.h @@ -56,7 +56,7 @@ struct enzyme_unit : named_scaled_unit {}; -template +template using catalytic_activity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/charge_density.h b/src/include/units/physical/si/charge_density.h index 653bab627..36b77c9dc 100644 --- a/src/include/units/physical/si/charge_density.h +++ b/src/include/units/physical/si/charge_density.h @@ -36,10 +36,10 @@ struct coulomb_per_metre_sq : unit {}; struct dim_charge_density : physical::dim_charge_density {}; struct dim_surface_charge_density : physical::dim_surface_charge_density {}; -template +template using charge_density = quantity; -template +template using surface_charge_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/concentration.h b/src/include/units/physical/si/concentration.h index ac7038e2a..4a7750097 100644 --- a/src/include/units/physical/si/concentration.h +++ b/src/include/units/physical/si/concentration.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct mol_per_metre_cub : unit {}; struct dim_concentration : physical::dim_concentration {}; -template +template using concentration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/conductance.h b/src/include/units/physical/si/conductance.h index 7b3676cd8..2f464cff2 100644 --- a/src/include/units/physical/si/conductance.h +++ b/src/include/units/physical/si/conductance.h @@ -49,7 +49,7 @@ struct yottasiemens : prefixed_unit {}; struct dim_conductance : physical::dim_conductance {}; -template +template using conductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index 79955cb69..9569306fd 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -52,7 +52,7 @@ struct yottaampere : prefixed_unit {}; struct dim_electric_current : physical::dim_electric_current {}; -template +template using current = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/current_density.h b/src/include/units/physical/si/current_density.h index 573ad58d7..d54cac8f2 100644 --- a/src/include/units/physical/si/current_density.h +++ b/src/include/units/physical/si/current_density.h @@ -34,7 +34,7 @@ struct ampere_per_metre_sq : unit {}; struct dim_current_density : physical::dim_current_density {}; -template +template using current_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/density.h b/src/include/units/physical/si/density.h index 735a89600..566c23247 100644 --- a/src/include/units/physical/si/density.h +++ b/src/include/units/physical/si/density.h @@ -34,7 +34,7 @@ struct kilogram_per_metre_cub : unit {}; struct dim_density : physical::dim_density {}; -template +template using density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/dynamic_viscosity.h b/src/include/units/physical/si/dynamic_viscosity.h index 3255cf093..0c6258b38 100644 --- a/src/include/units/physical/si/dynamic_viscosity.h +++ b/src/include/units/physical/si/dynamic_viscosity.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct pascal_second : unit {}; struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity {}; -template +template using dynamic_viscosity = 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 50742e4ab..b505efd1c 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -33,7 +33,7 @@ struct coulomb : named_unit {}; struct dim_electric_charge : physical::dim_electric_charge {}; -template +template using electric_charge = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/electric_field_strength.h b/src/include/units/physical/si/electric_field_strength.h index 8578f576e..d96bedb8d 100644 --- a/src/include/units/physical/si/electric_field_strength.h +++ b/src/include/units/physical/si/electric_field_strength.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct volt_per_metre : unit {}; struct dim_electric_field_strength : physical::dim_electric_field_strength {}; -template +template using electric_field_strength = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index 466663eb5..d05effd4d 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -52,7 +52,7 @@ struct gigaelectronvolt : prefixed_unit {} struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/force.h b/src/include/units/physical/si/force.h index 07adced40..76f8ca341 100644 --- a/src/include/units/physical/si/force.h +++ b/src/include/units/physical/si/force.h @@ -54,7 +54,7 @@ struct yottanewton : prefixed_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/frequency.h b/src/include/units/physical/si/frequency.h index a0a5d1100..88076e05e 100644 --- a/src/include/units/physical/si/frequency.h +++ b/src/include/units/physical/si/frequency.h @@ -48,7 +48,7 @@ struct yottahertz : prefixed_unit {}; struct dim_frequency : physical::dim_frequency {}; -template +template using frequency = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/heat_capacity.h b/src/include/units/physical/si/heat_capacity.h index 8cf3fe140..8208d6b98 100644 --- a/src/include/units/physical/si/heat_capacity.h +++ b/src/include/units/physical/si/heat_capacity.h @@ -39,13 +39,13 @@ struct dim_heat_capacity : physical::dim_heat_capacity {}; struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity {}; -template +template using heat_capacity = quantity; -template +template using specific_heat_capacity = quantity; -template +template using molar_heat_capacity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/inductance.h b/src/include/units/physical/si/inductance.h index 794909eef..1b4bc23d1 100644 --- a/src/include/units/physical/si/inductance.h +++ b/src/include/units/physical/si/inductance.h @@ -50,7 +50,7 @@ struct yottahenry : prefixed_unit {}; struct dim_inductance : physical::dim_inductance {}; -template +template using inductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index 71d4f4361..25e8417f2 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -54,7 +54,7 @@ struct astronomical_unit : named_scaled_unit {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminance.h b/src/include/units/physical/si/luminance.h index 389a6c464..5e30b9bf9 100644 --- a/src/include/units/physical/si/luminance.h +++ b/src/include/units/physical/si/luminance.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct candela_per_metre_sq : unit {}; struct dim_luminance : physical::dim_luminance {}; -template +template using luminance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminous_intensity.h b/src/include/units/physical/si/luminous_intensity.h index ac57c0a8c..4ccfb6a10 100644 --- a/src/include/units/physical/si/luminous_intensity.h +++ b/src/include/units/physical/si/luminous_intensity.h @@ -52,7 +52,7 @@ struct yottacandela : prefixed_unit {}; struct dim_luminous_intensity : physical::dim_luminous_intensity {}; -template +template using luminous_intensity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_flux.h b/src/include/units/physical/si/magnetic_flux.h index deeb545a1..38e060d19 100644 --- a/src/include/units/physical/si/magnetic_flux.h +++ b/src/include/units/physical/si/magnetic_flux.h @@ -50,7 +50,7 @@ struct yottaweber : prefixed_unit {}; struct dim_magnetic_flux : physical::dim_magnetic_flux {}; -template +template using magnetic_flux = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_induction.h b/src/include/units/physical/si/magnetic_induction.h index 5d11e6139..ecfb0a68c 100644 --- a/src/include/units/physical/si/magnetic_induction.h +++ b/src/include/units/physical/si/magnetic_induction.h @@ -54,7 +54,7 @@ struct gauss : named_scaled_unit, tesla> {} struct dim_magnetic_induction : physical::dim_magnetic_induction {}; -template +template using magnetic_induction = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index 5efd813f8..8293a0d41 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -76,7 +76,7 @@ struct dalton : named_scaled_unit {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/molar_energy.h b/src/include/units/physical/si/molar_energy.h index 88323b96e..6844e477d 100644 --- a/src/include/units/physical/si/molar_energy.h +++ b/src/include/units/physical/si/molar_energy.h @@ -34,7 +34,7 @@ struct joule_per_mole : unit {}; struct dim_molar_energy : physical::dim_molar_energy {}; -template +template using molar_energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h index 3266eb07e..17e775a60 100644 --- a/src/include/units/physical/si/momentum.h +++ b/src/include/units/physical/si/momentum.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct kilogram_metre_per_second : unit {}; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permeability.h b/src/include/units/physical/si/permeability.h index 4930ace53..e338786e6 100644 --- a/src/include/units/physical/si/permeability.h +++ b/src/include/units/physical/si/permeability.h @@ -33,7 +33,7 @@ struct henry_per_metre : unit {}; struct dim_permeability : physical::dim_permeability {}; -template +template using permeability = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permittivity.h b/src/include/units/physical/si/permittivity.h index 40f69cf71..df5ce8698 100644 --- a/src/include/units/physical/si/permittivity.h +++ b/src/include/units/physical/si/permittivity.h @@ -33,7 +33,7 @@ struct farad_per_metre : unit {}; struct dim_permittivity : physical::dim_permittivity {}; -template +template using permittivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/power.h b/src/include/units/physical/si/power.h index 91c565d03..a33344f59 100644 --- a/src/include/units/physical/si/power.h +++ b/src/include/units/physical/si/power.h @@ -49,7 +49,7 @@ struct yottawatt : prefixed_unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index 53ed1eff8..15b2f81b5 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -54,7 +54,7 @@ struct yottapascal : prefixed_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/resistance.h b/src/include/units/physical/si/resistance.h index b7d86dc50..0f2158543 100644 --- a/src/include/units/physical/si/resistance.h +++ b/src/include/units/physical/si/resistance.h @@ -50,7 +50,7 @@ struct yottaohm : prefixed_unit {}; struct dim_resistance : physical::dim_resistance {}; -template +template using resistance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/speed.h b/src/include/units/physical/si/speed.h index 2f4210187..f4506af5a 100644 --- a/src/include/units/physical/si/speed.h +++ b/src/include/units/physical/si/speed.h @@ -34,7 +34,7 @@ struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/substance.h b/src/include/units/physical/si/substance.h index 5e9dd5e7a..7edba442b 100644 --- a/src/include/units/physical/si/substance.h +++ b/src/include/units/physical/si/substance.h @@ -32,7 +32,7 @@ struct mole : named_unit {}; struct dim_substance : physical::dim_substance {}; -template +template using substance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/surface_tension.h b/src/include/units/physical/si/surface_tension.h index b077f54f4..883834d31 100644 --- a/src/include/units/physical/si/surface_tension.h +++ b/src/include/units/physical/si/surface_tension.h @@ -32,7 +32,7 @@ struct newton_per_metre : unit {}; struct dim_surface_tension : physical::dim_surface_tension {}; -template +template using surface_tension = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index 2b3b05573..dedcd8228 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -31,7 +31,7 @@ struct kelvin : named_unit {}; struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature {}; -template +template using temperature = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/thermal_conductivity.h b/src/include/units/physical/si/thermal_conductivity.h index 0a7a88f18..ebea135c7 100644 --- a/src/include/units/physical/si/thermal_conductivity.h +++ b/src/include/units/physical/si/thermal_conductivity.h @@ -33,7 +33,7 @@ struct watt_per_metre_kelvin : unit {}; struct dim_thermal_conductivity : physical::dim_thermal_conductivity {}; -template +template using thermal_conductivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index 273252f9c..b5cd4888b 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -43,7 +43,7 @@ struct day : named_scaled_unit, hour> {}; struct dim_time : physical::dim_time {}; -template +template using time = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/torque.h b/src/include/units/physical/si/torque.h index 6632a2d15..7e6f64f96 100644 --- a/src/include/units/physical/si/torque.h +++ b/src/include/units/physical/si/torque.h @@ -34,7 +34,7 @@ struct newton_metre : named_unit {}; struct dim_torque : physical::dim_torque {}; -template +template using torque = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index 68dac06e4..11e7099b7 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -54,7 +54,7 @@ struct yottavolt : prefixed_unit {}; struct dim_voltage : physical::dim_voltage {}; -template +template using voltage = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/volume.h b/src/include/units/physical/si/volume.h index 00e43ad86..e147b34ee 100644 --- a/src/include/units/physical/si/volume.h +++ b/src/include/units/physical/si/volume.h @@ -74,7 +74,7 @@ struct exalitre : prefixed_unit {}; struct zettalitre : prefixed_alias_unit {}; struct yottalitre : prefixed_unit {}; -template +template using volume = quantity; inline namespace literals { diff --git a/src/include/units/prefix.h b/src/include/units/prefix.h index 27dc10650..d01adaef9 100644 --- a/src/include/units/prefix.h +++ b/src/include/units/prefix.h @@ -31,7 +31,7 @@ namespace units { /** * @brief The base for all prefix families * - * Every prefix family should inherit from this type to satisfy PrefixFamily concept. + * Every prefix family should inherit from this type to satisfy in_prefix_family concept. */ struct prefix_family {}; @@ -45,7 +45,7 @@ struct no_prefix : prefix_family {}; namespace detail { -template +template struct prefix_base : downcast_base> { using prefix_family = PF; using ratio = R; @@ -68,7 +68,7 @@ struct prefix_base : downcast_base> { * @tparam Symbol a text representation of the prefix * @tparam R factor to be used to scale a unit */ -template +template requires (!std::same_as) struct prefix : downcast_child> { static constexpr auto symbol = Symbol; diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index e08e1828a..f5b8b3e2c 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -56,7 +56,7 @@ concept safe_divisible = // exposition only * Property of a phenomenon, body, or substance, where the property has a magnitude that can be * expressed by means of a number and a measurement unit. * - * @tparam D a dimension of the quantity (can be either a BaseDimension or a DerivedDimension) + * @tparam D a dimension of the quantity (can be either a in_base_dimension or a in_derived_dimension) * @tparam U a measurement unit of the quantity * @tparam Rep a type to be used to represent values of a quantity */ diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index 4f56f9e8a..aa1c1d569 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -289,21 +289,21 @@ struct quantity_cast_impl { } }; -template +template struct cast_ratio; -template +template struct cast_ratio { using type = ratio_divide; }; -template +template requires same_unit_reference::value struct cast_ratio { using type = ratio_divide; }; -template +template struct cast_ratio { using from_ratio = ratio_multiply; using to_ratio = ratio_multiply; @@ -367,7 +367,7 @@ template * * @tparam ToU a unit type to use for a target quantity */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) requires UnitOf { diff --git a/src/include/units/ratio.h b/src/include/units/ratio.h index 9495828f0..64a3e19e7 100644 --- a/src/include/units/ratio.h +++ b/src/include/units/ratio.h @@ -41,7 +41,7 @@ namespace units { * * @tparam Num Numerator * @tparam Den Denominator (default @c 1) - * @tparam Exp Exponent (default @c 0) + * @tparam Exp in_exponent (default @c 0) */ template requires(Den != 0) @@ -75,7 +75,7 @@ inline constexpr bool is_ratio> = true; // unused, and align exponents process could be subject to overflow in extreme cases -// template +// template // constexpr auto ratio_add_detail() { // std::intmax_t num1 = R1::num; // std::intmax_t num2 = R2::num; @@ -105,7 +105,7 @@ inline constexpr bool is_ratio> = true; // } -// template +// template // struct ratio_add_impl { // static constexpr auto detail = ratio_add_detail(); // using type = ratio; @@ -114,12 +114,12 @@ inline constexpr bool is_ratio> = true; // ratio_add : not used -// template +// template // using ratio_add = detail::ratio_add_impl::type; // ratio_subtract : not used // TODO implement ratio_subtract -// template +// template // using ratio_subtract = detail::ratio_subtract_impl::type; // ratio_multiply @@ -166,7 +166,7 @@ struct ratio_multiply_impl { } // namespace detail -template +template using ratio_multiply = detail::ratio_multiply_impl::type; // ratio_divide @@ -184,7 +184,7 @@ struct ratio_divide_impl { } // namespace detail -template +template using ratio_divide = detail::ratio_divide_impl::type; // ratio_pow @@ -208,7 +208,7 @@ struct ratio_pow_impl { } // namespace detail -template +template using ratio_pow = detail::ratio_pow_impl::type; // ratio_sqrt @@ -237,7 +237,7 @@ static constexpr std::intmax_t sqrt_impl(std::intmax_t v) return root; } -template +template constexpr auto make_exp_even() { if constexpr (R::exp % 2 == 0) @@ -263,7 +263,7 @@ struct ratio_sqrt_impl> { } // namespace detail -template +template using ratio_sqrt = detail::ratio_sqrt_impl::type; // common_ratio @@ -282,7 +282,7 @@ struct common_ratio_impl { } // namespace detail -template +template using common_ratio = detail::common_ratio_impl::type; } // namespace units diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 1c32ae24c..80bd8220a 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -50,16 +50,16 @@ namespace units { * @tparam U a unit to use as a reference for this dimension * @tparam R a ratio of a reference unit */ -template +template struct scaled_unit : downcast_base> { using ratio = R; using reference = U; }; -template +template using downcast_unit = downcast::reference>>; -template +template struct same_unit_reference : std::is_same {}; /** @@ -95,7 +95,7 @@ struct unknown_coherent_unit : unit {}; * @tparam Symbol a short text representation of the unit * @tparam PF no_prefix or a type of prefix family */ -template +template struct named_unit : downcast_child, Child>> { static constexpr bool is_named = true; static constexpr auto symbol = Symbol; @@ -116,7 +116,7 @@ struct named_unit : downcast_child, Child>> { * @tparam R a scale to apply to U * @tparam U a reference unit to scale */ -template +template struct named_scaled_unit : downcast_child, typename U::reference>> { static constexpr bool is_named = true; static constexpr auto symbol = Symbol; @@ -134,7 +134,7 @@ struct named_scaled_unit : downcast_child +template requires U::is_named && std::same_as struct prefixed_unit : downcast_child, typename U::reference>> { @@ -156,7 +156,7 @@ struct prefixed_unit : * @tparam U the unit of the first composite dimension from provided derived dimension's recipe * @tparam URest the units for the rest of dimensions from the recipe */ -template +template requires detail::same_scaled_units && (U::is_named && (URest::is_named && ... && true)) struct deduced_unit : downcast_child> { @@ -165,7 +165,7 @@ struct deduced_unit : downcast_child +// template // struct named_deduced_derived_unit : downcast_child> { // static constexpr bool is_named = true; // static constexpr auto symbol = Symbol; @@ -181,11 +181,11 @@ struct deduced_unit : downcast_child +template struct alias_unit : U { static constexpr bool is_named = true; static constexpr auto symbol = Symbol; @@ -199,15 +199,15 @@ struct alias_unit : U { * prefix. It is only possible to create such a unit if the given prefix type matches the one * defined in a reference unit. * - * @tparam U Unit for which an alias is defined + * @tparam U in_unit for which an alias is defined * @tparam P prefix to be appied to the reference unit * @tparam AU reference alias unit */ // TODO gcc bug: 95015 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95015 -// template +// template // requires (!AliasUnit) && std::same_as -template +template requires std::same_as struct prefixed_alias_unit : U { static constexpr bool is_named = true; diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index 2e04988b5..f40afda55 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -35,14 +35,14 @@ using namespace units::physical::si; struct sq_volt_per_hertz : unit {}; struct dim_power_spectral_density : derived_dimension, units::exp> {}; -template +template using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; struct dim_amplitude_spectral_density : derived_dimension, units::exp> {}; -template +template using amplitude_spectral_density = quantity; } diff --git a/test/unit_test/static/dimension_op_test.cpp b/test/unit_test/static/dimension_op_test.cpp index 84d5c281c..ab3fd119f 100644 --- a/test/unit_test/static/dimension_op_test.cpp +++ b/test/unit_test/static/dimension_op_test.cpp @@ -50,7 +50,7 @@ struct typeinfo; template using dim_unpack = detail::dim_unpack::type; -template +template using derived_dim = detail::derived_dimension_base; static_assert(std::is_same_v, exp_list<>>); diff --git a/test/unit_test/static/ratio_test.cpp b/test/unit_test/static/ratio_test.cpp index 7e68a2fef..5d448fe02 100644 --- a/test/unit_test/static/ratio_test.cpp +++ b/test/unit_test/static/ratio_test.cpp @@ -26,7 +26,7 @@ using namespace units; - template + template inline constexpr bool same = R1::num == R2::num && R1::den == R2::den && R1::exp == R2::exp; static_assert(same, ratio<1, 2>>); From f578ab9c9f71d9e6b1d3352b6329445434345cdb Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 7 Jun 2020 13:12:34 +0100 Subject: [PATCH 4/6] rename concepts 3 --- .../conversion_factor.cpp | 2 +- example/alternative_namespaces/units_str.h | 2 +- example/conversion_factor.cpp | 2 +- ...lman_filter-alpha_beta_filter_example2.cpp | 2 +- example/linear_algebra.cpp | 6 +- example/measurement.cpp | 2 +- src/include/units/bits/common_quantity.h | 6 +- src/include/units/bits/dimension_op.h | 28 +++---- src/include/units/bits/to_string.h | 6 +- src/include/units/concepts.h | 40 ++++----- src/include/units/customization_points.h | 4 +- src/include/units/data/bitrate.h | 2 +- src/include/units/data/information.h | 2 +- src/include/units/exp.h | 2 +- src/include/units/format.h | 16 ++-- src/include/units/math.h | 34 ++++---- src/include/units/physical/cgs/acceleration.h | 2 +- src/include/units/physical/cgs/area.h | 2 +- src/include/units/physical/cgs/energy.h | 2 +- src/include/units/physical/cgs/force.h | 2 +- src/include/units/physical/cgs/length.h | 2 +- src/include/units/physical/cgs/mass.h | 2 +- src/include/units/physical/cgs/power.h | 2 +- src/include/units/physical/cgs/pressure.h | 2 +- src/include/units/physical/cgs/speed.h | 2 +- src/include/units/physical/dimensions.h | 82 +++++++++---------- .../units/physical/natural/constants.h | 2 +- .../units/physical/natural/dimensions.h | 16 ++-- src/include/units/physical/si/absorbed_dose.h | 2 +- src/include/units/physical/si/acceleration.h | 2 +- src/include/units/physical/si/angle.h | 2 +- src/include/units/physical/si/area.h | 2 +- src/include/units/physical/si/capacitance.h | 2 +- .../units/physical/si/catalytic_activity.h | 2 +- .../units/physical/si/charge_density.h | 4 +- src/include/units/physical/si/concentration.h | 2 +- src/include/units/physical/si/conductance.h | 2 +- src/include/units/physical/si/constants.h | 18 ++-- src/include/units/physical/si/current.h | 2 +- .../units/physical/si/current_density.h | 2 +- src/include/units/physical/si/density.h | 2 +- .../units/physical/si/dynamic_viscosity.h | 2 +- .../units/physical/si/electric_charge.h | 2 +- .../physical/si/electric_field_strength.h | 2 +- src/include/units/physical/si/energy.h | 2 +- src/include/units/physical/si/force.h | 2 +- src/include/units/physical/si/frequency.h | 2 +- src/include/units/physical/si/heat_capacity.h | 6 +- src/include/units/physical/si/inductance.h | 2 +- src/include/units/physical/si/length.h | 2 +- src/include/units/physical/si/luminance.h | 2 +- .../units/physical/si/luminous_intensity.h | 2 +- src/include/units/physical/si/magnetic_flux.h | 2 +- .../units/physical/si/magnetic_induction.h | 2 +- src/include/units/physical/si/mass.h | 2 +- src/include/units/physical/si/molar_energy.h | 2 +- src/include/units/physical/si/momentum.h | 2 +- src/include/units/physical/si/permeability.h | 2 +- src/include/units/physical/si/permittivity.h | 2 +- src/include/units/physical/si/power.h | 2 +- src/include/units/physical/si/pressure.h | 2 +- src/include/units/physical/si/resistance.h | 2 +- src/include/units/physical/si/speed.h | 2 +- src/include/units/physical/si/substance.h | 2 +- .../units/physical/si/surface_tension.h | 2 +- src/include/units/physical/si/temperature.h | 2 +- .../units/physical/si/thermal_conductivity.h | 2 +- src/include/units/physical/si/time.h | 2 +- src/include/units/physical/si/torque.h | 2 +- src/include/units/physical/si/voltage.h | 2 +- src/include/units/physical/si/volume.h | 2 +- src/include/units/quantity.h | 44 +++++----- src/include/units/quantity_cast.h | 32 ++++---- src/include/units/random.h | 46 +++++------ src/include/units/unit.h | 4 +- .../static/custom_rep_min_req_test.cpp | 12 +-- test/unit_test/static/custom_unit_test.cpp | 4 +- test/unit_test/static/quantity_test.cpp | 2 +- 78 files changed, 263 insertions(+), 263 deletions(-) diff --git a/example/alternative_namespaces/conversion_factor.cpp b/example/alternative_namespaces/conversion_factor.cpp index 8e11a66e3..a75d11c46 100644 --- a/example/alternative_namespaces/conversion_factor.cpp +++ b/example/alternative_namespaces/conversion_factor.cpp @@ -27,7 +27,7 @@ namespace { -template +template requires units::equivalent_dim inline constexpr std::common_type_t conversion_factor(Target, Source) { diff --git a/example/alternative_namespaces/units_str.h b/example/alternative_namespaces/units_str.h index 3b0bfacd6..c7dcda940 100644 --- a/example/alternative_namespaces/units_str.h +++ b/example/alternative_namespaces/units_str.h @@ -4,7 +4,7 @@ #include #include // get at the units text of the quantity, without its numeric value -inline auto constexpr units_str(const units::Quantity AUTO& q) +inline auto constexpr units_str(const units::in_quantity AUTO& q) { typedef std::remove_cvref_t qtype; return units::detail::unit_text(); diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 3f9ed02dc..5e432ded8 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -26,7 +26,7 @@ namespace { -template +template requires units::equivalent_dim inline constexpr std::common_type_t conversion_factor(Target, Source) { diff --git a/example/kalman_filter-alpha_beta_filter_example2.cpp b/example/kalman_filter-alpha_beta_filter_example2.cpp index 72369ea87..c4d2db659 100644 --- a/example/kalman_filter-alpha_beta_filter_example2.cpp +++ b/example/kalman_filter-alpha_beta_filter_example2.cpp @@ -12,7 +12,7 @@ namespace { -template +template struct state_variable { Q estimated_current_state; Q predicted_next_state; diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 94ab3e85d..e3fcfe392 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -201,10 +201,10 @@ void matrix_of_quantity_tests() matrix_of_quantity_divide_by_scalar(); } -template +template using length_v = si::length>; -template +template using force_v = si::force>; void quantity_of_vector_add() @@ -274,7 +274,7 @@ void quantity_of_vector_tests() quantity_of_vector_divide_by_scalar(); } -template +template using length_m = si::length>; void quantity_of_matrix_add() diff --git a/example/measurement.cpp b/example/measurement.cpp index a5399817d..288236d85 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -146,7 +146,7 @@ class measurement { value_type uncertainty_{}; }; -static_assert(units::NumericValue>); +static_assert(units::in_numeric_value>); } // namespace diff --git a/src/include/units/bits/common_quantity.h b/src/include/units/bits/common_quantity.h index e66f79b9b..756ffd980 100644 --- a/src/include/units/bits/common_quantity.h +++ b/src/include/units/bits/common_quantity.h @@ -26,7 +26,7 @@ namespace units { -template U, NumericValue Rep> +template U, in_numeric_value Rep> class quantity; namespace detail { @@ -59,7 +59,7 @@ struct common_quantity_impl, quantity, Rep> } // namespace detail -template> +template> requires equivalent_dim using common_quantity = detail::common_quantity_impl::type; @@ -75,7 +75,7 @@ namespace concepts { #endif -template +template requires units::equivalent_dim struct common_type { using type = units::common_quantity; diff --git a/src/include/units/bits/dimension_op.h b/src/include/units/bits/dimension_op.h index 6180ec9e3..abd1f3aae 100644 --- a/src/include/units/bits/dimension_op.h +++ b/src/include/units/bits/dimension_op.h @@ -30,7 +30,7 @@ namespace units { // equivalent_dim namespace detail { -template +template struct equivalent_dim_impl : std::false_type {}; template @@ -58,7 +58,7 @@ struct equivalent_dim_impl : std::disjunction, equi } // namespace detail -template +template inline constexpr bool equivalent_dim = detail::equivalent_dim_impl::value; /** @@ -89,7 +89,7 @@ struct check_unknown> { using type = unknown_dimension; }; -template +template struct downcast_dimension_impl; template @@ -104,13 +104,13 @@ struct downcast_dimension_impl { } // namespace detail -template +template using downcast_dimension = detail::downcast_dimension_impl::type; // dim_invert namespace detail { -template +template struct dim_invert_impl; template @@ -134,7 +134,7 @@ struct dim_invert_impl : dim_invert_impl> { } // namespace detail -template +template using dim_invert = detail::dim_invert_impl::type; // dimension_multiply @@ -162,10 +162,10 @@ struct to_dimension>> { * one element being a base dimension with exponent 1. In such a case the final dimension should be the base * dimension itself. */ -template +template using merge_dimension = to_dimension>::type>::type; -template +template struct dimension_multiply_impl; template @@ -190,16 +190,16 @@ struct dimension_multiply_impl { } // namespace detail -template +template using dimension_multiply = detail::dimension_multiply_impl::type; -template +template using dimension_divide = detail::dimension_multiply_impl>::type; // dimension_sqrt namespace detail { -template +template struct dimension_sqrt_impl; template @@ -224,13 +224,13 @@ struct dimension_sqrt_impl> { } // namespace detail -template +template using dimension_sqrt = detail::dimension_sqrt_impl::type; // dimension_pow namespace detail { -template +template struct dimension_pow_impl; template @@ -260,7 +260,7 @@ struct dimension_pow_impl, N> { } // namespace detail -template +template using dimension_pow = detail::dimension_pow_impl::type; } // namespace units diff --git a/src/include/units/bits/to_string.h b/src/include/units/bits/to_string.h index 937995858..19197509a 100644 --- a/src/include/units/bits/to_string.h +++ b/src/include/units/bits/to_string.h @@ -129,7 +129,7 @@ constexpr auto exp_list_with_named_units(exp_list) return type_list_join(); } -template +template constexpr auto derived_dimension_unit_text() { using recipe = Dim::recipe; @@ -140,7 +140,7 @@ constexpr auto derived_dimension_unit_text() template concept has_symbol = requires{ T::symbol; }; -template +template constexpr auto unit_text() { if constexpr(has_symbol) { @@ -164,7 +164,7 @@ constexpr auto unit_text() } } -template +template std::basic_string to_string(const Q& q) { std::basic_ostringstream s; diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index e592cc788..d7f0ae5fa 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -162,19 +162,19 @@ struct derived_dimension_base; template concept in_derived_dimension = is_instantiation, detail::derived_dimension_base>; -// Dimension +// in_dimension /** * @brief A concept matching all dimensions in the library. * * Satisfied by all dimension types for which either `in_base_dimension` or `in_derived_dimension` is `true`. */ template -concept Dimension = in_base_dimension || in_derived_dimension; +concept in_dimension = in_base_dimension || in_derived_dimension; // UnitOf namespace detail { -template +template struct dimension_unit_impl; template @@ -195,27 +195,27 @@ struct dimension_unit_impl { * Depending on the dimension type it returns a base unit (for base dimensions) * or a coherent unit (in case of derived dimensions). * - * @tparam D Dimension type to get the unit from. + * @tparam D in_dimension type to get the unit from. */ -template +template using dimension_unit = detail::dimension_unit_impl::type; /** * @brief A concept matching only units of a specified dimension. * - * Satisfied by all unit types that satisfy `in_unit`, `Dimension`, and for which + * Satisfied by all unit types that satisfy `in_unit`, `in_dimension`, and for which * `U::reference` and @c dimension_unit::reference denote the same unit type. * * @tparam U Type to verify. - * @tparam D Dimension type to use for verification. + * @tparam D in_dimension type to use for verification. */ template concept UnitOf = in_unit && - Dimension && + in_dimension && std::same_as::reference>; -// Quantity +// in_quantity namespace detail { template @@ -229,10 +229,10 @@ inline constexpr bool is_quantity = false; * Satisfied by all instantiations of :class:`quantity`. */ template -concept Quantity = detail::is_quantity; +concept in_quantity = detail::is_quantity; -// WrappedQuantity +// in_wrapped_quantity namespace detail { template @@ -240,20 +240,20 @@ inline constexpr bool is_wrapped_quantity = false; template requires requires { typename T::value_type; } -inline constexpr bool is_wrapped_quantity = Quantity || is_wrapped_quantity; +inline constexpr bool is_wrapped_quantity = in_quantity || is_wrapped_quantity; } // namespace detail /** * @brief A concept matching types that wrap quantity objects. * - * Satisfied by all wrapper types that satisfy `Quantity` + * Satisfied by all wrapper types that satisfy `in_quantity` * recursively (i.e. `std::optional>`). */ template -concept WrappedQuantity = detail::is_wrapped_quantity; +concept in_wrapped_quantity = detail::is_wrapped_quantity; -// NumericValue +// in_numeric_value namespace detail { @@ -278,14 +278,14 @@ concept not_constructible_from_integral = } // namespace detail /** - * @brief A concept matching non-Quantity types. + * @brief A concept matching non-in_quantity types. * - * Satisfied by types that satisfy `(!Quantity) && (!WrappedQuantity) && std::regular`. + * Satisfied by types that satisfy `(!in_quantity) && (!in_wrapped_quantity) && std::regular`. */ template -concept NumericValue = - (!Quantity) && - (!WrappedQuantity) && +concept in_numeric_value = + (!in_quantity) && + (!in_wrapped_quantity) && std::regular && (detail::constructible_from_integral || detail::not_constructible_from_integral); diff --git a/src/include/units/customization_points.h b/src/include/units/customization_points.h index 82fe56ffd..d164cc042 100644 --- a/src/include/units/customization_points.h +++ b/src/include/units/customization_points.h @@ -37,7 +37,7 @@ namespace units { * * @tparam Rep a representation type for which a type trait is defined */ -template +template inline constexpr bool treat_as_floating_point = std::is_floating_point_v; /** @@ -49,7 +49,7 @@ inline constexpr bool treat_as_floating_point = std::is_floating_point_v; * * @tparam Rep a representation type for which a type trait is defined */ -template +template struct quantity_values { static constexpr Rep zero() noexcept { return Rep(0); } static constexpr Rep one() noexcept { return Rep(1); } diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index 5bef46801..94e1b2677 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -41,7 +41,7 @@ struct pebibit_per_second : deduced_unit concept Bitrate = QuantityOf; -template +template using bitrate = quantity; inline namespace literals { diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index cd1f84571..835014b71 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -48,7 +48,7 @@ struct dim_information : base_dimension<"information", bit> {}; template concept Information = QuantityOf; -template +template using information = quantity; inline namespace literals { diff --git a/src/include/units/exp.h b/src/include/units/exp.h index 82e43bd31..0e0832da1 100644 --- a/src/include/units/exp.h +++ b/src/include/units/exp.h @@ -34,7 +34,7 @@ namespace units { * @tparam Num numinator of the factor * @tparam Den denominator of the factor */ -template +template struct exp { using dimension = Dim; static constexpr int num = Num; diff --git a/src/include/units/format.h b/src/include/units/format.h index bba47cf43..905d7ab26 100644 --- a/src/include/units/format.h +++ b/src/include/units/format.h @@ -233,7 +233,7 @@ namespace units { return format_to(out, fmt::to_string(buffer), val); } - template + template struct units_formatter { OutputIt out; Rep val; @@ -242,7 +242,7 @@ namespace units { unit_format_specs const & unit_specs; explicit units_formatter( - OutputIt o, quantity q, + OutputIt o, quantity q, global_format_specs const & gspecs, rep_format_specs const & rspecs, unit_format_specs const & uspecs ): @@ -263,7 +263,7 @@ namespace units { void on_quantity_unit([[maybe_unused]] const CharT) { - auto txt = unit_text(); + auto txt = unit_text(); auto txt_c_str = unit_specs.modifier == 'A' ? txt.ascii().c_str() : txt.standard().c_str(); format_to(out, "{}", txt_c_str); } @@ -273,10 +273,10 @@ namespace units { } // namespace units -template -struct fmt::formatter, CharT> { +template +struct fmt::formatter, CharT> { private: - using quantity = units::quantity; + using quantity = units::quantity; using iterator = fmt::basic_format_parse_context::iterator; using arg_ref_type = fmt::internal::arg_ref; @@ -414,7 +414,7 @@ struct fmt::formatter, CharT> { } template - auto format(const units::quantity& q, FormatContext& ctx) + auto format(const units::quantity& q, FormatContext& ctx) { auto begin = format_str.begin(), end = format_str.end(); @@ -461,7 +461,7 @@ struct fmt::formatter, CharT> { if(begin == end || *begin == '}') { // default format should print value followed by the unit separated with 1 space to_quantity_buffer = units::detail::format_units_quantity_value(to_quantity_buffer, q.count(), rep_specs); - constexpr auto symbol = units::detail::unit_text(); + constexpr auto symbol = units::detail::unit_text(); if(symbol.standard().size()) { *to_quantity_buffer++ = CharT(' '); format_to(to_quantity_buffer, "{}", symbol.standard().c_str()); diff --git a/src/include/units/math.h b/src/include/units/math.h index d42bac4a9..d1763144f 100644 --- a/src/include/units/math.h +++ b/src/include/units/math.h @@ -35,12 +35,12 @@ namespace units { * Both the quantity value and its dimension are the base of the operation. * * @tparam N in_exponent - * @param q Quantity being the base of the operation - * @return Quantity The result of computation + * @param q in_quantity being the base of the operation + * @return in_quantity The result of computation */ -template +template requires(N != 0) -inline Quantity AUTO pow(const Q& q) noexcept +inline in_quantity AUTO pow(const Q& q) noexcept requires requires { std::pow(q.count(), N); } { using dim = dimension_pow; @@ -55,7 +55,7 @@ inline Quantity AUTO pow(const Q& q) noexcept * * @return Rep A scalar value of @c 1. */ -template +template requires(N == 0) inline Q::rep pow(const Q&) noexcept { @@ -67,11 +67,11 @@ inline Q::rep pow(const Q&) noexcept * * Both the quantity value and its dimension are the base of the operation. * - * @param q Quantity being the base of the operation - * @return Quantity The result of computation + * @param q in_quantity being the base of the operation + * @return in_quantity The result of computation */ -template -inline Quantity AUTO sqrt(const Q& q) noexcept +template +inline in_quantity AUTO sqrt(const Q& q) noexcept requires requires { std::sqrt(q.count()); } { using dim = dimension_sqrt; @@ -84,11 +84,11 @@ inline Quantity AUTO sqrt(const Q& q) noexcept /** * @brief Computes the absolute value of a quantity * - * @param q Quantity being the base of the operation - * @return Quantity The absolute value of a provided quantity + * @param q in_quantity being the base of the operation + * @return in_quantity The absolute value of a provided quantity */ -template -constexpr Quantity AUTO abs(const Q& q) noexcept +template +constexpr in_quantity AUTO abs(const Q& q) noexcept requires requires { std::abs(q.count()); } { return Q(std::abs(q.count())); @@ -99,12 +99,12 @@ constexpr Quantity AUTO abs(const Q& q) noexcept * * The returned value is defined by a std::numeric_limits::epsilon(). * - * @tparam Q Quantity type being the base of the operation - * @return Quantity The epsilon value for quantity's representation type + * @tparam Q in_quantity type being the base of the operation + * @return in_quantity The epsilon value for quantity's representation type */ -template +template requires requires { std::numeric_limits::epsilon(); } -constexpr Quantity AUTO epsilon() noexcept +constexpr in_quantity AUTO epsilon() noexcept { return Q(std::numeric_limits::epsilon()); } diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index 9a421fa22..008736521 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::cgs { struct gal : named_unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/area.h b/src/include/units/physical/cgs/area.h index 2618acce7..946ac9949 100644 --- a/src/include/units/physical/cgs/area.h +++ b/src/include/units/physical/cgs/area.h @@ -33,7 +33,7 @@ using si::square_centimetre; struct dim_area : physical::dim_area {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/energy.h b/src/include/units/physical/cgs/energy.h index 5d8ee4ae3..e99bc6249 100644 --- a/src/include/units/physical/cgs/energy.h +++ b/src/include/units/physical/cgs/energy.h @@ -33,7 +33,7 @@ struct erg : named_unit {}; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/force.h b/src/include/units/physical/cgs/force.h index 5f35dee61..3389a0cb0 100644 --- a/src/include/units/physical/cgs/force.h +++ b/src/include/units/physical/cgs/force.h @@ -34,7 +34,7 @@ struct dyne : named_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/length.h b/src/include/units/physical/cgs/length.h index 0c483596f..2639251e0 100644 --- a/src/include/units/physical/cgs/length.h +++ b/src/include/units/physical/cgs/length.h @@ -32,7 +32,7 @@ using si::centimetre; struct dim_length : physical::dim_length {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/mass.h b/src/include/units/physical/cgs/mass.h index d1b34a848..26d006033 100644 --- a/src/include/units/physical/cgs/mass.h +++ b/src/include/units/physical/cgs/mass.h @@ -32,7 +32,7 @@ using si::gram; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/power.h b/src/include/units/physical/cgs/power.h index 5d2447b1e..6ea249e6f 100644 --- a/src/include/units/physical/cgs/power.h +++ b/src/include/units/physical/cgs/power.h @@ -33,7 +33,7 @@ struct erg_per_second : unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/pressure.h b/src/include/units/physical/cgs/pressure.h index 39930b3e0..b85d35bac 100644 --- a/src/include/units/physical/cgs/pressure.h +++ b/src/include/units/physical/cgs/pressure.h @@ -34,7 +34,7 @@ struct barye : named_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/cgs/speed.h b/src/include/units/physical/cgs/speed.h index f22404a62..5afb66ea8 100644 --- a/src/include/units/physical/cgs/speed.h +++ b/src/include/units/physical/cgs/speed.h @@ -32,7 +32,7 @@ namespace units::physical::cgs { struct centimetre_per_second : unit {}; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index ecd2c4401..8a04928e6 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -30,10 +30,10 @@ namespace units::physical { template typename DimTemplate> -concept DimensionOf = Dimension && is_derived_from_instantiation; +concept in_dimension_of = in_dimension && is_derived_from_instantiation; template typename DimTemplate> -concept QuantityOf = Quantity && is_derived_from_instantiation; +concept QuantityOf = in_quantity && is_derived_from_instantiation; // ------------------------ base dimensions ----------------------------- @@ -63,123 +63,123 @@ struct dim_angle : base_dimension<"A", U> {}; // ------------------------ derived dimensions ----------------------------- -template T> +template T> struct dim_frequency : derived_dimension> {}; -template L> +template L> struct dim_area : derived_dimension> {}; -template L> +template L> struct dim_volume : derived_dimension> {}; -template L, DimensionOf T> +template L, in_dimension_of T> struct dim_speed : derived_dimension, exp> {}; -template L, DimensionOf T> +template L, in_dimension_of T> struct dim_acceleration : derived_dimension, exp> {}; -template M, DimensionOf A> +template M, in_dimension_of A> struct dim_force : derived_dimension, exp> {}; -template M, DimensionOf V> +template M, in_dimension_of V> struct dim_momentum : derived_dimension, exp> {}; -template F, DimensionOf L> +template F, in_dimension_of L> struct dim_energy : derived_dimension, exp> {}; -template E, DimensionOf A> +template E, in_dimension_of A> struct dim_torque : derived_dimension, exp> {}; -template M, DimensionOf L> +template M, in_dimension_of L> struct dim_density : derived_dimension, exp> {}; -template E, DimensionOf T> +template E, in_dimension_of T> struct dim_power : derived_dimension, exp> {}; -template P, DimensionOf C> +template P, in_dimension_of C> struct dim_voltage : derived_dimension, exp> {}; -template V, DimensionOf C> +template V, in_dimension_of C> struct dim_resistance : derived_dimension, exp> {}; -template T, DimensionOf C> +template T, in_dimension_of C> struct dim_electric_charge : derived_dimension, exp> {}; -template C, DimensionOf V> +template C, in_dimension_of V> struct dim_capacitance : derived_dimension, exp> {}; -template F, DimensionOf L> +template F, in_dimension_of L> struct dim_surface_tension : derived_dimension, exp> {}; -template F, DimensionOf A> +template F, in_dimension_of A> struct dim_pressure : derived_dimension, exp> {}; -template V, DimensionOf T, DimensionOf L> +template V, in_dimension_of T, in_dimension_of L> struct dim_magnetic_induction : derived_dimension, exp, exp> {}; -template B, DimensionOf A> +template B, in_dimension_of A> struct dim_magnetic_flux : derived_dimension, exp> {}; -template F, DimensionOf I> +template F, in_dimension_of I> struct dim_inductance : derived_dimension, exp> {}; -template R> +template R> struct dim_conductance : derived_dimension> {}; // TODO Add when downcasting issue is solved -// template T> +// template T> // struct dim_radioactivity : derived_dimension> {}; -template T, DimensionOf M> +template T, in_dimension_of M> struct dim_catalytic_activity : derived_dimension, exp> {}; -template E, DimensionOf M> +template E, in_dimension_of M> struct dim_absorbed_dose : derived_dimension, exp> {}; -template I, DimensionOf L> +template I, in_dimension_of L> struct dim_current_density : derived_dimension, exp> {}; -template M, DimensionOf L> +template M, in_dimension_of L> struct dim_concentration : derived_dimension, exp> {}; -template I, DimensionOf L> +template I, in_dimension_of L> struct dim_luminance : derived_dimension, exp> {}; -template P, DimensionOf T> +template P, in_dimension_of T> struct dim_dynamic_viscosity : derived_dimension, exp> {}; -template E, DimensionOf T> +template E, in_dimension_of T> struct dim_heat_capacity : derived_dimension, exp> {}; -template C, DimensionOf M> +template C, in_dimension_of M> struct dim_specific_heat_capacity : derived_dimension, exp> {}; -template C, DimensionOf M> +template C, in_dimension_of M> struct dim_molar_heat_capacity : derived_dimension, exp> {}; -template P, DimensionOf L, DimensionOf T> +template P, in_dimension_of L, in_dimension_of T> struct dim_thermal_conductivity : derived_dimension, exp, exp> {}; // TODO Add when downcasting issue is solved -// template E, DimensionOf L> +// template E, in_dimension_of L> // struct dim_energy_density : derived_dimension, exp> {}; -template V, DimensionOf L> +template V, in_dimension_of L> struct dim_electric_field_strength : derived_dimension, exp> {}; -template Q, DimensionOf L> +template Q, in_dimension_of L> struct dim_charge_density : derived_dimension, exp> {}; -template Q, DimensionOf L> +template Q, in_dimension_of L> struct dim_surface_charge_density : derived_dimension, exp> {}; -template C, DimensionOf L> +template C, in_dimension_of L> struct dim_permittivity : derived_dimension, exp> {}; -template H, DimensionOf L> +template H, in_dimension_of L> struct dim_permeability : derived_dimension, exp> {}; -template E, DimensionOf M> +template E, in_dimension_of M> struct dim_molar_energy : derived_dimension, exp> {}; template diff --git a/src/include/units/physical/natural/constants.h b/src/include/units/physical/natural/constants.h index a7aa0b07d..8edae1b9b 100644 --- a/src/include/units/physical/natural/constants.h +++ b/src/include/units/physical/natural/constants.h @@ -26,7 +26,7 @@ namespace units::physical::natural { -template +template inline constexpr auto speed_of_light = speed(1); } // namespace units::physical::natural diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index b97ae2e75..4934c9070 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -29,35 +29,35 @@ namespace units::physical::natural { struct dim_length : physical::dim_length {}; -template +template using length = quantity; struct dim_time : physical::dim_time {}; -template +template using time = quantity; struct dim_mass : physical::dim_mass {}; -template +template using mass = quantity; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; struct dim_force : physical::dim_force {}; -template +template using force = quantity; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; // Typical UDLs will not work here as the same units are reused by many quantities. diff --git a/src/include/units/physical/si/absorbed_dose.h b/src/include/units/physical/si/absorbed_dose.h index 4713416f3..7ec008b2f 100644 --- a/src/include/units/physical/si/absorbed_dose.h +++ b/src/include/units/physical/si/absorbed_dose.h @@ -54,7 +54,7 @@ struct yottagray : prefixed_unit {}; struct dim_absorbed_dose : physical::dim_absorbed_dose {}; -template +template using absorbed_dose = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index 19ffd3278..56fb489ba 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct metre_per_second_sq : unit {}; struct dim_acceleration : physical::dim_acceleration {}; -template +template using acceleration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/angle.h b/src/include/units/physical/si/angle.h index 29d2d560c..02aa0a04c 100644 --- a/src/include/units/physical/si/angle.h +++ b/src/include/units/physical/si/angle.h @@ -32,7 +32,7 @@ struct radian : named_unit {}; struct dim_angle : physical::dim_angle {}; -template +template using angle = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index 8eb0027a9..2b1bf3c41 100644 --- a/src/include/units/physical/si/area.h +++ b/src/include/units/physical/si/area.h @@ -54,7 +54,7 @@ struct square_yottametre : deduced_unit struct hectare : alias_unit {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/capacitance.h b/src/include/units/physical/si/capacitance.h index dfb835882..834c4ab5e 100644 --- a/src/include/units/physical/si/capacitance.h +++ b/src/include/units/physical/si/capacitance.h @@ -54,7 +54,7 @@ struct yottafarad : prefixed_unit {}; struct dim_capacitance : physical::dim_capacitance {}; -template +template using capacitance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/catalytic_activity.h b/src/include/units/physical/si/catalytic_activity.h index 3aa7b186f..bfeafa5b2 100644 --- a/src/include/units/physical/si/catalytic_activity.h +++ b/src/include/units/physical/si/catalytic_activity.h @@ -56,7 +56,7 @@ struct enzyme_unit : named_scaled_unit {}; -template +template using catalytic_activity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/charge_density.h b/src/include/units/physical/si/charge_density.h index 36b77c9dc..6181fd48e 100644 --- a/src/include/units/physical/si/charge_density.h +++ b/src/include/units/physical/si/charge_density.h @@ -36,10 +36,10 @@ struct coulomb_per_metre_sq : unit {}; struct dim_charge_density : physical::dim_charge_density {}; struct dim_surface_charge_density : physical::dim_surface_charge_density {}; -template +template using charge_density = quantity; -template +template using surface_charge_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/concentration.h b/src/include/units/physical/si/concentration.h index 4a7750097..b4cc4df91 100644 --- a/src/include/units/physical/si/concentration.h +++ b/src/include/units/physical/si/concentration.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct mol_per_metre_cub : unit {}; struct dim_concentration : physical::dim_concentration {}; -template +template using concentration = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/conductance.h b/src/include/units/physical/si/conductance.h index 2f464cff2..061195fd3 100644 --- a/src/include/units/physical/si/conductance.h +++ b/src/include/units/physical/si/conductance.h @@ -49,7 +49,7 @@ struct yottasiemens : prefixed_unit {}; struct dim_conductance : physical::dim_conductance {}; -template +template using conductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/constants.h b/src/include/units/physical/si/constants.h index 5c02a2e0e..245b988d4 100644 --- a/src/include/units/physical/si/constants.h +++ b/src/include/units/physical/si/constants.h @@ -32,31 +32,31 @@ namespace units::physical::si::si2019 { -template +template inline constexpr auto planck_constant = energy(6.62607015e-34) * time(1); -template +template inline constexpr auto reduced_planck_constant = energy(6.582119569e-10) * time(1); -template +template inline constexpr auto elementary_charge = electric_charge(1.602176634e-19); -template +template inline constexpr auto boltzmann_constant = energy(1.380649e-23) / temperature(1); -template +template inline constexpr auto avogadro_constant = Rep(6.02214076e23) / substance(1); -template +template inline constexpr auto speed_of_light = speed(299'792'458); -template +template inline constexpr auto hyperfine_structure_transition_frequency = frequency(9'192'631'770); -// template +// template // inline constexpr auto luminous_efficacy = 683q_lm / 1q_W; -template +template inline constexpr auto standard_gravity = acceleration(9.80665); } // namespace units::physical::si::si2019 diff --git a/src/include/units/physical/si/current.h b/src/include/units/physical/si/current.h index 9569306fd..026e3dc03 100644 --- a/src/include/units/physical/si/current.h +++ b/src/include/units/physical/si/current.h @@ -52,7 +52,7 @@ struct yottaampere : prefixed_unit {}; struct dim_electric_current : physical::dim_electric_current {}; -template +template using current = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/current_density.h b/src/include/units/physical/si/current_density.h index d54cac8f2..e96954d35 100644 --- a/src/include/units/physical/si/current_density.h +++ b/src/include/units/physical/si/current_density.h @@ -34,7 +34,7 @@ struct ampere_per_metre_sq : unit {}; struct dim_current_density : physical::dim_current_density {}; -template +template using current_density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/density.h b/src/include/units/physical/si/density.h index 566c23247..1d7bdb456 100644 --- a/src/include/units/physical/si/density.h +++ b/src/include/units/physical/si/density.h @@ -34,7 +34,7 @@ struct kilogram_per_metre_cub : unit {}; struct dim_density : physical::dim_density {}; -template +template using density = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/dynamic_viscosity.h b/src/include/units/physical/si/dynamic_viscosity.h index 0c6258b38..547ffd09a 100644 --- a/src/include/units/physical/si/dynamic_viscosity.h +++ b/src/include/units/physical/si/dynamic_viscosity.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct pascal_second : unit {}; struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity {}; -template +template using dynamic_viscosity = 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 b505efd1c..c942566a4 100644 --- a/src/include/units/physical/si/electric_charge.h +++ b/src/include/units/physical/si/electric_charge.h @@ -33,7 +33,7 @@ struct coulomb : named_unit {}; struct dim_electric_charge : physical::dim_electric_charge {}; -template +template using electric_charge = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/electric_field_strength.h b/src/include/units/physical/si/electric_field_strength.h index d96bedb8d..75e9d825c 100644 --- a/src/include/units/physical/si/electric_field_strength.h +++ b/src/include/units/physical/si/electric_field_strength.h @@ -31,7 +31,7 @@ namespace units::physical::si { struct volt_per_metre : unit {}; struct dim_electric_field_strength : physical::dim_electric_field_strength {}; -template +template using electric_field_strength = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/energy.h b/src/include/units/physical/si/energy.h index d05effd4d..d27ec8e94 100644 --- a/src/include/units/physical/si/energy.h +++ b/src/include/units/physical/si/energy.h @@ -52,7 +52,7 @@ struct gigaelectronvolt : prefixed_unit {} struct dim_energy : physical::dim_energy {}; -template +template using energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/force.h b/src/include/units/physical/si/force.h index 76f8ca341..9349f267a 100644 --- a/src/include/units/physical/si/force.h +++ b/src/include/units/physical/si/force.h @@ -54,7 +54,7 @@ struct yottanewton : prefixed_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/frequency.h b/src/include/units/physical/si/frequency.h index 88076e05e..331d37723 100644 --- a/src/include/units/physical/si/frequency.h +++ b/src/include/units/physical/si/frequency.h @@ -48,7 +48,7 @@ struct yottahertz : prefixed_unit {}; struct dim_frequency : physical::dim_frequency {}; -template +template using frequency = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/heat_capacity.h b/src/include/units/physical/si/heat_capacity.h index 8208d6b98..d2907c991 100644 --- a/src/include/units/physical/si/heat_capacity.h +++ b/src/include/units/physical/si/heat_capacity.h @@ -39,13 +39,13 @@ struct dim_heat_capacity : physical::dim_heat_capacity {}; struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity {}; -template +template using heat_capacity = quantity; -template +template using specific_heat_capacity = quantity; -template +template using molar_heat_capacity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/inductance.h b/src/include/units/physical/si/inductance.h index 1b4bc23d1..b5388125a 100644 --- a/src/include/units/physical/si/inductance.h +++ b/src/include/units/physical/si/inductance.h @@ -50,7 +50,7 @@ struct yottahenry : prefixed_unit {}; struct dim_inductance : physical::dim_inductance {}; -template +template using inductance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/length.h b/src/include/units/physical/si/length.h index 25e8417f2..1a88c7fc4 100644 --- a/src/include/units/physical/si/length.h +++ b/src/include/units/physical/si/length.h @@ -54,7 +54,7 @@ struct astronomical_unit : named_scaled_unit {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminance.h b/src/include/units/physical/si/luminance.h index 5e30b9bf9..ec1961309 100644 --- a/src/include/units/physical/si/luminance.h +++ b/src/include/units/physical/si/luminance.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct candela_per_metre_sq : unit {}; struct dim_luminance : physical::dim_luminance {}; -template +template using luminance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/luminous_intensity.h b/src/include/units/physical/si/luminous_intensity.h index 4ccfb6a10..cc4c32a03 100644 --- a/src/include/units/physical/si/luminous_intensity.h +++ b/src/include/units/physical/si/luminous_intensity.h @@ -52,7 +52,7 @@ struct yottacandela : prefixed_unit {}; struct dim_luminous_intensity : physical::dim_luminous_intensity {}; -template +template using luminous_intensity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_flux.h b/src/include/units/physical/si/magnetic_flux.h index 38e060d19..c341ae85a 100644 --- a/src/include/units/physical/si/magnetic_flux.h +++ b/src/include/units/physical/si/magnetic_flux.h @@ -50,7 +50,7 @@ struct yottaweber : prefixed_unit {}; struct dim_magnetic_flux : physical::dim_magnetic_flux {}; -template +template using magnetic_flux = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/magnetic_induction.h b/src/include/units/physical/si/magnetic_induction.h index ecfb0a68c..5d6552a94 100644 --- a/src/include/units/physical/si/magnetic_induction.h +++ b/src/include/units/physical/si/magnetic_induction.h @@ -54,7 +54,7 @@ struct gauss : named_scaled_unit, tesla> {} struct dim_magnetic_induction : physical::dim_magnetic_induction {}; -template +template using magnetic_induction = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/mass.h b/src/include/units/physical/si/mass.h index 8293a0d41..a70a04c93 100644 --- a/src/include/units/physical/si/mass.h +++ b/src/include/units/physical/si/mass.h @@ -76,7 +76,7 @@ struct dalton : named_scaled_unit {}; -template +template using mass = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/molar_energy.h b/src/include/units/physical/si/molar_energy.h index 6844e477d..cdf11b255 100644 --- a/src/include/units/physical/si/molar_energy.h +++ b/src/include/units/physical/si/molar_energy.h @@ -34,7 +34,7 @@ struct joule_per_mole : unit {}; struct dim_molar_energy : physical::dim_molar_energy {}; -template +template using molar_energy = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h index 17e775a60..26e188410 100644 --- a/src/include/units/physical/si/momentum.h +++ b/src/include/units/physical/si/momentum.h @@ -32,7 +32,7 @@ namespace units::physical::si { struct kilogram_metre_per_second : unit {}; struct dim_momentum : physical::dim_momentum {}; -template +template using momentum = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permeability.h b/src/include/units/physical/si/permeability.h index e338786e6..421796267 100644 --- a/src/include/units/physical/si/permeability.h +++ b/src/include/units/physical/si/permeability.h @@ -33,7 +33,7 @@ struct henry_per_metre : unit {}; struct dim_permeability : physical::dim_permeability {}; -template +template using permeability = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/permittivity.h b/src/include/units/physical/si/permittivity.h index df5ce8698..3b72d544c 100644 --- a/src/include/units/physical/si/permittivity.h +++ b/src/include/units/physical/si/permittivity.h @@ -33,7 +33,7 @@ struct farad_per_metre : unit {}; struct dim_permittivity : physical::dim_permittivity {}; -template +template using permittivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/power.h b/src/include/units/physical/si/power.h index a33344f59..bea352858 100644 --- a/src/include/units/physical/si/power.h +++ b/src/include/units/physical/si/power.h @@ -49,7 +49,7 @@ struct yottawatt : prefixed_unit {}; struct dim_power : physical::dim_power {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/pressure.h b/src/include/units/physical/si/pressure.h index 15b2f81b5..22643f24d 100644 --- a/src/include/units/physical/si/pressure.h +++ b/src/include/units/physical/si/pressure.h @@ -54,7 +54,7 @@ struct yottapascal : prefixed_unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/resistance.h b/src/include/units/physical/si/resistance.h index 0f2158543..46e632534 100644 --- a/src/include/units/physical/si/resistance.h +++ b/src/include/units/physical/si/resistance.h @@ -50,7 +50,7 @@ struct yottaohm : prefixed_unit {}; struct dim_resistance : physical::dim_resistance {}; -template +template using resistance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/speed.h b/src/include/units/physical/si/speed.h index f4506af5a..8b916a232 100644 --- a/src/include/units/physical/si/speed.h +++ b/src/include/units/physical/si/speed.h @@ -34,7 +34,7 @@ struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/substance.h b/src/include/units/physical/si/substance.h index 7edba442b..bd12baaed 100644 --- a/src/include/units/physical/si/substance.h +++ b/src/include/units/physical/si/substance.h @@ -32,7 +32,7 @@ struct mole : named_unit {}; struct dim_substance : physical::dim_substance {}; -template +template using substance = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/surface_tension.h b/src/include/units/physical/si/surface_tension.h index 883834d31..d59d54630 100644 --- a/src/include/units/physical/si/surface_tension.h +++ b/src/include/units/physical/si/surface_tension.h @@ -32,7 +32,7 @@ struct newton_per_metre : unit {}; struct dim_surface_tension : physical::dim_surface_tension {}; -template +template using surface_tension = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/temperature.h b/src/include/units/physical/si/temperature.h index dedcd8228..45ed7d920 100644 --- a/src/include/units/physical/si/temperature.h +++ b/src/include/units/physical/si/temperature.h @@ -31,7 +31,7 @@ struct kelvin : named_unit {}; struct dim_thermodynamic_temperature : physical::dim_thermodynamic_temperature {}; -template +template using temperature = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/thermal_conductivity.h b/src/include/units/physical/si/thermal_conductivity.h index ebea135c7..ac9b2d5e9 100644 --- a/src/include/units/physical/si/thermal_conductivity.h +++ b/src/include/units/physical/si/thermal_conductivity.h @@ -33,7 +33,7 @@ struct watt_per_metre_kelvin : unit {}; struct dim_thermal_conductivity : physical::dim_thermal_conductivity {}; -template +template using thermal_conductivity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/time.h b/src/include/units/physical/si/time.h index b5cd4888b..9230931f2 100644 --- a/src/include/units/physical/si/time.h +++ b/src/include/units/physical/si/time.h @@ -43,7 +43,7 @@ struct day : named_scaled_unit, hour> {}; struct dim_time : physical::dim_time {}; -template +template using time = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/torque.h b/src/include/units/physical/si/torque.h index 7e6f64f96..8329498d1 100644 --- a/src/include/units/physical/si/torque.h +++ b/src/include/units/physical/si/torque.h @@ -34,7 +34,7 @@ struct newton_metre : named_unit {}; struct dim_torque : physical::dim_torque {}; -template +template using torque = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/voltage.h b/src/include/units/physical/si/voltage.h index 11e7099b7..21694686e 100644 --- a/src/include/units/physical/si/voltage.h +++ b/src/include/units/physical/si/voltage.h @@ -54,7 +54,7 @@ struct yottavolt : prefixed_unit {}; struct dim_voltage : physical::dim_voltage {}; -template +template using voltage = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/volume.h b/src/include/units/physical/si/volume.h index e147b34ee..b124b72e5 100644 --- a/src/include/units/physical/si/volume.h +++ b/src/include/units/physical/si/volume.h @@ -74,7 +74,7 @@ struct exalitre : prefixed_unit {}; struct zettalitre : prefixed_alias_unit {}; struct yottalitre : prefixed_unit {}; -template +template using volume = quantity; inline namespace literals { diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index f5b8b3e2c..d4412903d 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -60,7 +60,7 @@ concept safe_divisible = // exposition only * @tparam U a measurement unit of the quantity * @tparam Rep a type to be used to represent values of a quantity */ -template U, NumericValue Rep = double> +template U, in_numeric_value Rep = double> class quantity { Rep value_{}; @@ -73,11 +73,11 @@ class quantity { quantity(const quantity&) = default; quantity(quantity&&) = default; - template + template requires detail::safe_convertible constexpr explicit quantity(const Val& v) : value_{static_cast(v)} {} - template + template requires equivalent_dim && detail::safe_convertible && detail::safe_divisible @@ -200,12 +200,12 @@ class quantity { return *this; } - template + template constexpr quantity& operator%=(const Val& rhs) requires (!treat_as_floating_point) && (!treat_as_floating_point) && requires(T v1, Val v2) { { v1 %= v2 } -> SAME_AS(T&); } - // requires(rep v1, NumericValue v2) { { v1 %= v2 } -> SAME_AS(rep&); } // TODO gated by gcc-9 (fixed in gcc-10) + // requires(rep v1, in_numeric_value v2) { { v1 %= v2 } -> SAME_AS(rep&); } // TODO gated by gcc-9 (fixed in gcc-10) { value_ %= rhs; return *this; @@ -305,7 +305,7 @@ class quantity { }; template -[[nodiscard]] constexpr Quantity AUTO operator+(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_quantity AUTO operator+(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> { using common_rep = decltype(lhs.count() + rhs.count()); @@ -314,7 +314,7 @@ template } template -[[nodiscard]] constexpr Quantity AUTO operator-(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_quantity AUTO operator-(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> { using common_rep = decltype(lhs.count() - rhs.count()); @@ -322,8 +322,8 @@ template return ret(ret(lhs).count() - ret(rhs).count()); } -template -[[nodiscard]] constexpr Quantity AUTO operator*(const quantity& q, const Val& v) +template +[[nodiscard]] constexpr in_quantity AUTO operator*(const quantity& q, const Val& v) requires std::regular_invocable, Rep, Val> { using common_rep = decltype(q.count() * v); @@ -331,15 +331,15 @@ template return ret(q.count() * v); } -template -[[nodiscard]] constexpr Quantity AUTO operator*(const Val& v, const quantity& q) +template +[[nodiscard]] constexpr in_quantity AUTO operator*(const Val& v, const quantity& q) requires std::regular_invocable, Val, Rep> { return q * v; } template -[[nodiscard]] constexpr NumericValue AUTO operator*(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_numeric_value AUTO operator*(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim> { @@ -353,7 +353,7 @@ template -[[nodiscard]] constexpr Quantity AUTO operator*(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_quantity AUTO operator*(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> { using dim = dimension_multiply; @@ -366,8 +366,8 @@ template -[[nodiscard]] constexpr Quantity AUTO operator/(const Val& v, const quantity& q) +template +[[nodiscard]] constexpr in_quantity AUTO operator/(const Val& v, const quantity& q) requires std::regular_invocable, Val, Rep> { Expects(q.count() != 0); @@ -380,8 +380,8 @@ template return ret(v / q.count()); } -template -[[nodiscard]] constexpr Quantity AUTO operator/(const quantity& q, const Val& v) +template +[[nodiscard]] constexpr in_quantity AUTO operator/(const quantity& q, const Val& v) requires std::regular_invocable, Rep, Val> { Expects(v != Val{0}); @@ -392,7 +392,7 @@ template } template -[[nodiscard]] constexpr NumericValue AUTO operator/(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_numeric_value AUTO operator/(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> && equivalent_dim { @@ -404,7 +404,7 @@ template -[[nodiscard]] constexpr Quantity AUTO operator/(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_quantity AUTO operator/(const quantity& lhs, const quantity& rhs) requires std::regular_invocable, Rep1, Rep2> { Expects(rhs.count() != 0); @@ -419,8 +419,8 @@ template -[[nodiscard]] constexpr Quantity AUTO operator%(const quantity& q, const Val& v) +template +[[nodiscard]] constexpr in_quantity AUTO operator%(const quantity& q, const Val& v) requires (!treat_as_floating_point) && (!treat_as_floating_point) && std::regular_invocable, Rep, Val> @@ -431,7 +431,7 @@ template } template -[[nodiscard]] constexpr Quantity AUTO operator%(const quantity& lhs, const quantity& rhs) +[[nodiscard]] constexpr in_quantity AUTO operator%(const quantity& lhs, const quantity& rhs) requires (!treat_as_floating_point) && (!treat_as_floating_point) && std::regular_invocable, Rep1, Rep2> diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index aa1c1d569..7730a8687 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -63,7 +63,7 @@ constexpr long double fpow10(std::intmax_t exp) // QuantityOf template -concept QuantityOf = Quantity && Dimension && equivalent_dim; +concept QuantityOf = in_quantity && in_dimension && equivalent_dim; // quantity_cast namespace detail { @@ -73,7 +73,7 @@ struct quantity_cast_impl; template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { return To(static_cast(q.count())); @@ -82,7 +82,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -138,7 +138,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { return To(static_cast(static_cast(q.count()) / static_cast(CRatio::den))); @@ -147,7 +147,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -165,7 +165,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { return To(static_cast(static_cast(q.count()) * static_cast(CRatio::num))); @@ -174,7 +174,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -192,7 +192,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -237,7 +237,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { return To(static_cast(q.count() / CRatio::den)); @@ -246,7 +246,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -264,7 +264,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { return To(static_cast(q.count() * CRatio::num)); @@ -273,7 +273,7 @@ struct quantity_cast_impl { template struct quantity_cast_impl { - template + template static constexpr To cast(const Q& q) { if constexpr (treat_as_floating_point) { @@ -289,7 +289,7 @@ struct quantity_cast_impl { } }; -template +template struct cast_ratio; template @@ -324,7 +324,7 @@ struct cast_ratio { * * @tparam To a target quantity type to cast to */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) requires QuantityOf { @@ -348,7 +348,7 @@ template * * @tparam ToD a dimension type to use for a target quantity */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) requires equivalent_dim { @@ -386,7 +386,7 @@ template * * @tparam ToRep a representation type to use for a target quantity */ -template +template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) { return quantity_cast>(q); diff --git a/src/include/units/random.h b/src/include/units/random.h index 97000502a..71f2f95f3 100644 --- a/src/include/units/random.h +++ b/src/include/units/random.h @@ -29,7 +29,7 @@ namespace units { namespace detail { - template + template static std::vector i_qty_to_rep(InputIt first, InputIt last) { std::vector intervals_rep; @@ -38,7 +38,7 @@ namespace detail { return intervals_rep; } - template + template static std::vector bl_qty_to_rep(std::initializer_list& bl) { std::vector bl_rep; @@ -47,7 +47,7 @@ namespace detail { return bl_rep; } - template + template inline static std::vector fw_bl_pwc(std::initializer_list& bl, UnaryOperation fw) { using rep = Q::rep; @@ -61,7 +61,7 @@ namespace detail { return weights; } - template + template static std::vector fw_bl_pwl(std::initializer_list& bl, UnaryOperation fw) { std::vector weights; @@ -71,7 +71,7 @@ namespace detail { } } // namespace detail -template +template requires std::integral struct uniform_int_distribution : public std::uniform_int_distribution { @@ -91,7 +91,7 @@ struct uniform_int_distribution : public std::uniform_int_distribution +template requires std::floating_point struct uniform_real_distribution : public std::uniform_real_distribution { @@ -111,7 +111,7 @@ struct uniform_real_distribution : public std::uniform_real_distribution +template requires std::integral struct binomial_distribution : public std::binomial_distribution { @@ -130,7 +130,7 @@ struct binomial_distribution : public std::binomial_distribution +template requires std::integral struct negative_binomial_distribution : public std::negative_binomial_distribution { @@ -149,7 +149,7 @@ struct negative_binomial_distribution : public std::negative_binomial_distributi Q max() const { return Q(base::max()); } }; -template +template requires std::integral struct geometric_distribution : public std::geometric_distribution { @@ -166,7 +166,7 @@ struct geometric_distribution : public std::geometric_distribution +template requires std::integral struct poisson_distribution : public std::poisson_distribution { @@ -183,7 +183,7 @@ struct poisson_distribution : public std::poisson_distribution Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point struct exponential_distribution : public std::exponential_distribution { @@ -200,7 +200,7 @@ struct exponential_distribution : public std::exponential_distribution +template requires std::floating_point struct gamma_distribution : public std::gamma_distribution { @@ -217,7 +217,7 @@ struct gamma_distribution : public std::gamma_distribution Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point struct weibull_distribution : public std::weibull_distribution { @@ -234,7 +234,7 @@ struct weibull_distribution : public std::weibull_distribution Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point struct extreme_value_distribution : public std::extreme_value_distribution { @@ -253,7 +253,7 @@ struct extreme_value_distribution : public std::extreme_value_distribution +template requires std::floating_point struct normal_distribution : public std::normal_distribution { @@ -273,7 +273,7 @@ struct normal_distribution : public std::normal_distribution Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point struct lognormal_distribution : public std::lognormal_distribution { @@ -293,7 +293,7 @@ struct lognormal_distribution : public std::lognormal_distribution +template requires std::floating_point struct chi_squared_distribution : public std::chi_squared_distribution { @@ -310,7 +310,7 @@ struct chi_squared_distribution : public std::chi_squared_distribution +template requires std::floating_point struct cauchy_distribution : public std::cauchy_distribution { @@ -330,7 +330,7 @@ struct cauchy_distribution : public std::cauchy_distribution Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point struct fisher_f_distribution : public std::fisher_f_distribution { @@ -347,7 +347,7 @@ struct fisher_f_distribution : public std::fisher_f_distribution +template requires std::floating_point struct student_t_distribution : public std::student_t_distribution { @@ -364,7 +364,7 @@ struct student_t_distribution : public std::student_t_distribution +template requires std::integral struct discrete_distribution : public std::discrete_distribution { @@ -389,7 +389,7 @@ struct discrete_distribution : public std::discrete_distribution +template requires std::floating_point class piecewise_constant_distribution : public std::piecewise_constant_distribution { @@ -434,7 +434,7 @@ class piecewise_constant_distribution : public std::piecewise_constant_distribut Q max() const { return Q(base::max()); } }; -template +template requires std::floating_point class piecewise_linear_distribution : public std::piecewise_linear_distribution { diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 80bd8220a..f203211eb 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -56,7 +56,7 @@ struct scaled_unit : downcast_base> { using reference = U; }; -template +template using downcast_unit = downcast::reference>>; template @@ -165,7 +165,7 @@ struct deduced_unit : downcast_child +// template // struct named_deduced_derived_unit : downcast_child> { // static constexpr bool is_named = true; // static constexpr auto symbol = Symbol; diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index a35aff35f..a01f5e133 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -85,7 +85,7 @@ using impl_impl = impl_constructible_impl_convertible; static_assert(std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::NumericValue>); +static_assert(units::in_numeric_value>); template struct expl_constructible_impl_convertible : scalar_ops> { @@ -100,7 +100,7 @@ using expl_impl = expl_constructible_impl_convertible; static_assert(!std::convertible_to>); static_assert(std::convertible_to, float>); -static_assert(units::NumericValue>); +static_assert(units::in_numeric_value>); template struct impl_constructible_expl_convertible : scalar_ops> { @@ -115,7 +115,7 @@ using impl_expl = impl_constructible_expl_convertible; static_assert(std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::NumericValue>); +static_assert(units::in_numeric_value>); template struct expl_constructible_expl_convertible : scalar_ops> { @@ -130,7 +130,7 @@ using expl_expl = expl_constructible_expl_convertible; static_assert(!std::convertible_to>); static_assert(!std::convertible_to, float>); -static_assert(units::NumericValue>); +static_assert(units::in_numeric_value>); } // namespace @@ -169,7 +169,7 @@ using namespace units::physical::si; // constructors -// Quantity from NumericValue +// in_quantity from in_numeric_value // int <- int static_assert(length(expl_impl(1)).count() == 1); // static_assert(length(impl_expl(1)).count() == 1); // should not compile (not convertible) @@ -198,7 +198,7 @@ static_assert(length>(1).count() == impl_expl{1 // static_assert(length(expl_impl(1.0)).count() == 1); // should not compile (truncating conversion) // static_assert(length>(1.0).count() == impl_expl{1}); // should not compile (truncating conversion) -// Quantity from other Quantity with different Rep +// in_quantity from other in_quantity with different Rep // int <- int static_assert(length(length>(expl_impl(1))).count() == 1); // static_assert(length(length>(1)).count() == 1); // should not compile (not convertible) diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index f40afda55..ea8285624 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -35,14 +35,14 @@ using namespace units::physical::si; struct sq_volt_per_hertz : unit {}; struct dim_power_spectral_density : derived_dimension, units::exp> {}; -template +template using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; struct dim_amplitude_spectral_density : derived_dimension, units::exp> {}; -template +template using amplitude_spectral_density = quantity; } diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 1c0e4cb45..186cce623 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -213,7 +213,7 @@ static_assert(2q_dm3 + 2q_cm3 == 2002q_ml); // is_quantity -static_assert(Quantity>); +static_assert(in_quantity>); // common_quantity From ca97a6cdf3cb3a9959c15c3672a9ff2caa6de6e4 Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 7 Jun 2020 13:24:29 +0100 Subject: [PATCH 5/6] concepts rename 4 --- src/include/units/data/bitrate.h | 2 +- src/include/units/data/information.h | 2 +- src/include/units/physical/dimensions.h | 94 ++++++++++++------------- src/include/units/quantity_cast.h | 6 +- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/include/units/data/bitrate.h b/src/include/units/data/bitrate.h index 94e1b2677..4e5bacd7f 100644 --- a/src/include/units/data/bitrate.h +++ b/src/include/units/data/bitrate.h @@ -39,7 +39,7 @@ struct tebibit_per_second : deduced_unit {}; template -concept Bitrate = QuantityOf; +concept in_bitrate = in_quantity_of; template using bitrate = quantity; diff --git a/src/include/units/data/information.h b/src/include/units/data/information.h index 835014b71..8b6a4b7ab 100644 --- a/src/include/units/data/information.h +++ b/src/include/units/data/information.h @@ -46,7 +46,7 @@ struct pebibyte : prefixed_unit {}; struct dim_information : base_dimension<"information", bit> {}; template -concept Information = QuantityOf; +concept in_information = in_quantity_of; template using information = quantity; diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index 8a04928e6..31f341112 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -33,7 +33,7 @@ template typename DimTemplate> concept in_dimension_of = in_dimension && is_derived_from_instantiation; template typename DimTemplate> -concept QuantityOf = in_quantity && is_derived_from_instantiation; +concept in_quantity_of = in_quantity && is_derived_from_instantiation; // ------------------------ base dimensions ----------------------------- @@ -183,143 +183,143 @@ template E, in_dimension_ struct dim_molar_energy : derived_dimension, exp> {}; template -concept Length = QuantityOf; +concept Length = in_quantity_of; template -concept Mass = QuantityOf; +concept Mass = in_quantity_of; template -concept Time = QuantityOf; +concept Time = in_quantity_of; template -concept Current = QuantityOf; +concept Current = in_quantity_of; template -concept Temperature = QuantityOf; +concept Temperature = in_quantity_of; template -concept Substance = QuantityOf; +concept Substance = in_quantity_of; template -concept LuminousIntensity = QuantityOf; +concept LuminousIntensity = in_quantity_of; template -concept Angle = QuantityOf; +concept Angle = in_quantity_of; template -concept Frequency = QuantityOf; +concept Frequency = in_quantity_of; template -concept Area = QuantityOf; +concept Area = in_quantity_of; template -concept Volume = QuantityOf; +concept Volume = in_quantity_of; template -concept Speed = QuantityOf; +concept Speed = in_quantity_of; template -concept Acceleration = QuantityOf; +concept Acceleration = in_quantity_of; template -concept Force = QuantityOf; +concept Force = in_quantity_of; template -concept Momentum = QuantityOf; +concept Momentum = in_quantity_of; template -concept Energy = QuantityOf; +concept Energy = in_quantity_of; template -concept Torque = QuantityOf; +concept Torque = in_quantity_of; template -concept Density = QuantityOf; +concept Density = in_quantity_of; template -concept Power = QuantityOf; +concept Power = in_quantity_of; template -concept Voltage = QuantityOf; +concept Voltage = in_quantity_of; template -concept ElectricCharge = QuantityOf; +concept ElectricCharge = in_quantity_of; template -concept Capacitance = QuantityOf; +concept Capacitance = in_quantity_of; template -concept SurfaceTension = QuantityOf; +concept SurfaceTension = in_quantity_of; template -concept Pressure = QuantityOf; +concept Pressure = in_quantity_of; template -concept MagneticInduction = QuantityOf; +concept MagneticInduction = in_quantity_of; template -concept MagneticFlux = QuantityOf; +concept MagneticFlux = in_quantity_of; template -concept Inductance = QuantityOf; +concept Inductance = in_quantity_of; template -concept Conductance = QuantityOf; +concept Conductance = in_quantity_of; // TODO Add when downcasting issue is solved // template -// concept Radioactivity = QuantityOf; +// concept Radioactivity = in_quantity_of; template -concept CatalyticActivity = QuantityOf; +concept CatalyticActivity = in_quantity_of; template -concept AbsorbedDose = QuantityOf; +concept AbsorbedDose = in_quantity_of; template -concept CurrentDensity = QuantityOf; +concept CurrentDensity = in_quantity_of; template -concept Concentration = QuantityOf; +concept Concentration = in_quantity_of; template -concept Luminance = QuantityOf; +concept Luminance = in_quantity_of; template -concept DynamicViscosity = QuantityOf; +concept DynamicViscosity = in_quantity_of; template -concept HeatCapacity = QuantityOf; +concept HeatCapacity = in_quantity_of; template -concept SpecificHeatCapacity = QuantityOf; +concept SpecificHeatCapacity = in_quantity_of; template -concept MolarHeatCapacity = QuantityOf; +concept MolarHeatCapacity = in_quantity_of; template -concept ThermalConductivity = QuantityOf; +concept ThermalConductivity = in_quantity_of; // TODO Add when downcasting issue is solved // template -// concept EnergyDensity = QuantityOf; +// concept EnergyDensity = in_quantity_of; template -concept ElectricFieldStrength = QuantityOf; +concept ElectricFieldStrength = in_quantity_of; template -concept ChargeDensity = QuantityOf; +concept ChargeDensity = in_quantity_of; template -concept SurfaceChargeDensity = QuantityOf; +concept SurfaceChargeDensity = in_quantity_of; template -concept Permittivity = QuantityOf; +concept Permittivity = in_quantity_of; template -concept Permeability = QuantityOf; +concept Permeability = in_quantity_of; template -concept MolarEnergy = QuantityOf; +concept MolarEnergy = in_quantity_of; } // namespace units::physical diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index 7730a8687..dfcaf9879 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -61,9 +61,9 @@ constexpr long double fpow10(std::intmax_t exp) } -// QuantityOf +// in_quantity_of template -concept QuantityOf = in_quantity && in_dimension && equivalent_dim; +concept in_quantity_of = in_quantity && in_dimension && equivalent_dim; // quantity_cast namespace detail { @@ -326,7 +326,7 @@ struct cast_ratio { */ template [[nodiscard]] constexpr auto quantity_cast(const quantity& q) - requires QuantityOf + requires in_quantity_of { using c_ratio = detail::cast_ratio::type; using c_rep = std::common_type_t; From 6266273feec76991980f78a9089b7086ce19c670 Mon Sep 17 00:00:00 2001 From: Andy Little Date: Sun, 7 Jun 2020 14:11:48 +0100 Subject: [PATCH 6/6] rename concepts 5 --- example/avg_speed.cpp | 18 +- example/capacitor_time_curve.cpp | 2 +- example/experimental_angle.cpp | 2 +- example/hello_units.cpp | 10 +- example/measurement.cpp | 2 +- example/total_energy.cpp | 14 +- example/unknown_dimension.cpp | 14 +- src/include/units/physical/dimensions.h | 88 +++++----- .../static/dimensions_concepts_test.cpp | 160 +++++++++--------- 9 files changed, 155 insertions(+), 155 deletions(-) diff --git a/example/avg_speed.cpp b/example/avg_speed.cpp index dcad8f5c6..a70ca67d6 100644 --- a/example/avg_speed.cpp +++ b/example/avg_speed.cpp @@ -44,18 +44,18 @@ fixed_double_si_avg_speed(si::length d, } template -constexpr Speed AUTO si_avg_speed(si::length d, +constexpr in_speed AUTO si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Speed AUTO avg_speed(Length AUTO d, Time AUTO t) +constexpr in_speed AUTO avg_speed(in_length AUTO d, in_time AUTO t) { return d / t; } -template +template void print_result(D distance, T duration, V speed) { const auto result_in_kmph = units::quantity_cast>(speed); @@ -68,7 +68,7 @@ void example() // SI (int) { using namespace units::physical::si::literals; - constexpr Length AUTO distance = 220q_km; // constructed from a UDL + constexpr in_length AUTO distance = 220q_km; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "SI units with 'int' as representation\n"; @@ -82,7 +82,7 @@ void example() // SI (double) { using namespace units::physical::si::literals; - constexpr Length AUTO distance = 220.q_km; // constructed from a UDL + constexpr in_length AUTO distance = 220.q_km; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "\nSI units with 'double' as representation\n"; @@ -98,7 +98,7 @@ void example() // Customary Units (int) { using namespace units::physical::international::literals; - constexpr Length AUTO distance = 140q_mi; // constructed from a UDL + constexpr in_length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "\nUS Customary Units with 'int' as representation\n"; @@ -114,7 +114,7 @@ void example() // Customary Units (double) { using namespace units::physical::international::literals; - constexpr Length AUTO distance = 140q_mi; // constructed from a UDL + constexpr in_length AUTO distance = 140q_mi; // constructed from a UDL constexpr si::time duration(2); // constructed from a value std::cout << "\nUS Customary Units with 'double' as representation\n"; @@ -132,7 +132,7 @@ void example() // CGS (int) { using namespace units::physical::cgs::literals; - constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL + constexpr in_length AUTO distance = 22'000'000q_cm; // constructed from a UDL constexpr cgs::time duration(2); // constructed from a value std::cout << "\nCGS units with 'int' as representation\n"; @@ -151,7 +151,7 @@ void example() // CGS (double) { using namespace units::physical::cgs::literals; - constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL + constexpr in_length AUTO distance = 22'000'000q_cm; // constructed from a UDL constexpr cgs::time duration(2); // constructed from a value std::cout << "\nCGS units with 'double' as representation\n"; diff --git a/example/capacitor_time_curve.cpp b/example/capacitor_time_curve.cpp index 04186e782..ae3df06c6 100644 --- a/example/capacitor_time_curve.cpp +++ b/example/capacitor_time_curve.cpp @@ -41,7 +41,7 @@ int main() constexpr auto R = 4.7q_kR; for (auto t = 0q_ms; t <= 50q_ms; ++t) { - const Voltage AUTO Vt = V0 * std::exp(-t / (R * C)); + const in_voltage AUTO Vt = V0 * std::exp(-t / (R * C)); std::cout << "at " << t << " voltage is "; diff --git a/example/experimental_angle.cpp b/example/experimental_angle.cpp index d15c75be3..7dce409aa 100644 --- a/example/experimental_angle.cpp +++ b/example/experimental_angle.cpp @@ -34,7 +34,7 @@ int main() auto torque = 20.0q_Nm; auto energy = 20.0q_J; - physical::Angle AUTO angle = torque / energy; + physical::in_angle AUTO angle = torque / energy; std::cout << angle << '\n'; } diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 25d20810d..1f2196914 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -27,7 +27,7 @@ using namespace units::physical; -constexpr Speed AUTO avg_speed(Length AUTO d, Time AUTO t) +constexpr in_speed AUTO avg_speed(in_length AUTO d, in_time AUTO t) { return d / t; } @@ -35,10 +35,10 @@ constexpr Speed AUTO avg_speed(Length AUTO d, Time AUTO t) int main() { using namespace units::physical::si::literals; - Speed AUTO v1 = avg_speed(220q_km, 2q_h); - Speed AUTO v2 = avg_speed(si::length(140), si::time(2)); - Speed AUTO v3 = quantity_cast(v2); - Speed AUTO v4 = quantity_cast(v3); + in_speed AUTO v1 = avg_speed(220q_km, 2q_h); + in_speed AUTO v2 = avg_speed(si::length(140), si::time(2)); + in_speed AUTO v3 = quantity_cast(v2); + in_speed AUTO v4 = quantity_cast(v3); std::cout << v1 << '\n'; // 110 km/h std::cout << fmt::format("{}", v2) << '\n'; // 70 mi/h diff --git a/example/measurement.cpp b/example/measurement.cpp index 288236d85..9cb85b742 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -162,7 +162,7 @@ void example() const auto a = si::acceleration>(measurement(9.8, 0.1)); const auto t = si::time>(measurement(1.2, 0.1)); - const Speed AUTO v1 = a * t; + const in_speed AUTO v1 = a * t; std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; si::length> length(measurement(123., 1.)); diff --git a/example/total_energy.cpp b/example/total_energy.cpp index 4b15ca92d..e0dd08f5c 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -32,7 +32,7 @@ namespace { using namespace units::physical; -Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Speed AUTO c) +in_energy AUTO total_energy(in_momentum AUTO p, in_mass AUTO m, in_speed AUTO c) { return sqrt(pow<2>(p * c) + pow<2>(m * pow<2>(c))); } @@ -42,13 +42,13 @@ void si_example() using namespace units::physical::si; using GeV = gigaelectronvolt; - constexpr Speed AUTO c = si2019::speed_of_light<>; + constexpr in_speed AUTO c = si2019::speed_of_light<>; std::cout << "\n*** SI units (c = " << c << ") ***\n"; - const Momentum AUTO p = 4.q_GeV / c; - const Mass AUTO m = 3.q_GeV / pow<2>(c); - const Energy AUTO E = total_energy(p, m, c); + const in_momentum AUTO p = 4.q_GeV / c; + const in_mass AUTO m = 3.q_GeV / pow<2>(c); + const in_energy AUTO E = total_energy(p, m, c); std::cout << "[in GeV]\n" << "p = " << p << "\n" @@ -73,10 +73,10 @@ void natural_example() using namespace units::physical::natural; using GeV = gigaelectronvolt; - constexpr Speed AUTO c = speed_of_light<>; + constexpr in_speed AUTO c = speed_of_light<>; const momentum p(4); const mass m(3); - const Energy AUTO E = total_energy(p, m, c); + const in_energy AUTO E = total_energy(p, m, c); std::cout << "\n*** Natural units (c = " << c << ") ***\n" << "p = " << p << "\n" diff --git a/example/unknown_dimension.cpp b/example/unknown_dimension.cpp index f6437b0c0..a273f7489 100644 --- a/example/unknown_dimension.cpp +++ b/example/unknown_dimension.cpp @@ -25,8 +25,8 @@ namespace { -template -constexpr units::physical::Speed AUTO avg_speed(D d, T t) +template +constexpr units::physical::in_speed AUTO avg_speed(D d, T t) { return d / t; } @@ -36,13 +36,13 @@ void example() using namespace units::physical; using namespace units::physical::si::literals; - Length AUTO d1 = 123q_m; - Time AUTO t1 = 10q_s; - Speed AUTO v1 = avg_speed(d1, t1); + in_length AUTO d1 = 123q_m; + in_time AUTO t1 = 10q_s; + in_speed AUTO v1 = avg_speed(d1, t1); auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Speed AUTO v2 = temp1 / 100q_m; // back to known dimensions again - Length AUTO d2 = v2 * 60q_s; + in_speed AUTO v2 = temp1 / 100q_m; // back to known dimensions again + in_length AUTO d2 = v2 * 60q_s; std::cout << "d1 = " << d1 << '\n'; std::cout << "t1 = " << t1 << '\n'; diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index 31f341112..a315208d3 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -183,143 +183,143 @@ template E, in_dimension_ struct dim_molar_energy : derived_dimension, exp> {}; template -concept Length = in_quantity_of; +concept in_length = in_quantity_of; template -concept Mass = in_quantity_of; +concept in_mass = in_quantity_of; template -concept Time = in_quantity_of; +concept in_time = in_quantity_of; template -concept Current = in_quantity_of; +concept in_current = in_quantity_of; template -concept Temperature = in_quantity_of; +concept in_temperature = in_quantity_of; template -concept Substance = in_quantity_of; +concept in_substance = in_quantity_of; template -concept LuminousIntensity = in_quantity_of; +concept in_luminous_intensity = in_quantity_of; template -concept Angle = in_quantity_of; +concept in_angle = in_quantity_of; template -concept Frequency = in_quantity_of; +concept in_frequency = in_quantity_of; template -concept Area = in_quantity_of; +concept in_area = in_quantity_of; template -concept Volume = in_quantity_of; +concept in_volume = in_quantity_of; template -concept Speed = in_quantity_of; +concept in_speed = in_quantity_of; template -concept Acceleration = in_quantity_of; +concept in_acceleration = in_quantity_of; template -concept Force = in_quantity_of; +concept in_force = in_quantity_of; template -concept Momentum = in_quantity_of; +concept in_momentum = in_quantity_of; template -concept Energy = in_quantity_of; +concept in_energy = in_quantity_of; template -concept Torque = in_quantity_of; +concept in_torque = in_quantity_of; template -concept Density = in_quantity_of; +concept in_density = in_quantity_of; template -concept Power = in_quantity_of; +concept in_power = in_quantity_of; template -concept Voltage = in_quantity_of; +concept in_voltage = in_quantity_of; template -concept ElectricCharge = in_quantity_of; +concept in_electric_charge = in_quantity_of; template -concept Capacitance = in_quantity_of; +concept in_capacitance = in_quantity_of; template -concept SurfaceTension = in_quantity_of; +concept in_surface_tension = in_quantity_of; template -concept Pressure = in_quantity_of; +concept in_pressure = in_quantity_of; template -concept MagneticInduction = in_quantity_of; +concept in_magnetic_induction = in_quantity_of; template -concept MagneticFlux = in_quantity_of; +concept in_magnetic_flux = in_quantity_of; template -concept Inductance = in_quantity_of; +concept in_inductance = in_quantity_of; template -concept Conductance = in_quantity_of; +concept in_conductance = in_quantity_of; // TODO Add when downcasting issue is solved // template // concept Radioactivity = in_quantity_of; template -concept CatalyticActivity = in_quantity_of; +concept in_catalytic_activity = in_quantity_of; template -concept AbsorbedDose = in_quantity_of; +concept in_absorbed_dose = in_quantity_of; template -concept CurrentDensity = in_quantity_of; +concept in_current_density = in_quantity_of; template -concept Concentration = in_quantity_of; +concept in_concentration = in_quantity_of; template -concept Luminance = in_quantity_of; +concept in_luminance = in_quantity_of; template -concept DynamicViscosity = in_quantity_of; +concept in_dynamic_viscosity = in_quantity_of; template -concept HeatCapacity = in_quantity_of; +concept in_heat_capacity = in_quantity_of; template -concept SpecificHeatCapacity = in_quantity_of; +concept in_specific_heat_capacity = in_quantity_of; template -concept MolarHeatCapacity = in_quantity_of; +concept in_molar_heat_capacity = in_quantity_of; template -concept ThermalConductivity = in_quantity_of; +concept in_thermal_conductivity = in_quantity_of; // TODO Add when downcasting issue is solved // template // concept EnergyDensity = in_quantity_of; template -concept ElectricFieldStrength = in_quantity_of; +concept in_electric_field_strength = in_quantity_of; template -concept ChargeDensity = in_quantity_of; +concept in_charge_density = in_quantity_of; template -concept SurfaceChargeDensity = in_quantity_of; +concept in_surface_charge_density = in_quantity_of; template -concept Permittivity = in_quantity_of; +concept in_permittivity = in_quantity_of; template -concept Permeability = in_quantity_of; +concept in_permeability = in_quantity_of; template -concept MolarEnergy = in_quantity_of; +concept in_molar_energy = in_quantity_of; } // namespace units::physical diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index bf3b57968..afce3cbcd 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -27,132 +27,132 @@ namespace { using namespace units::physical; -static_assert(Length>); -static_assert(!Length>); +static_assert(in_length>); +static_assert(!in_length>); -static_assert(Mass>); -static_assert(!Mass>); +static_assert(in_mass>); +static_assert(!in_mass>); -static_assert(Time>); -static_assert(!Time>); +static_assert(in_time>); +static_assert(!in_time>); -static_assert(Current>); -static_assert(!Current>); +static_assert(in_current>); +static_assert(!in_current>); -static_assert(Temperature>); -static_assert(!Temperature>); +static_assert(in_temperature>); +static_assert(!in_temperature>); -static_assert(Substance>); -static_assert(!Substance>); +static_assert(in_substance>); +static_assert(!in_substance>); -static_assert(LuminousIntensity>); -static_assert(!LuminousIntensity>); +static_assert(in_luminous_intensity>); +static_assert(!in_luminous_intensity>); -static_assert(Frequency>); -static_assert(!Frequency>); +static_assert(in_frequency>); +static_assert(!in_frequency>); -static_assert(Area>); -static_assert(!Area>); +static_assert(in_area>); +static_assert(!in_area>); -static_assert(Volume>); -static_assert(!Volume>); +static_assert(in_volume>); +static_assert(!in_volume>); -static_assert(Speed>); -static_assert(!Speed>); +static_assert(in_speed>); +static_assert(!in_speed>); -static_assert(Acceleration>); -static_assert(!Acceleration>); +static_assert(in_acceleration>); +static_assert(!in_acceleration>); -static_assert(Force>); -static_assert(!Force>); +static_assert(in_force>); +static_assert(!in_force>); -static_assert(Energy>); -static_assert(!Energy>); +static_assert(in_energy>); +static_assert(!in_energy>); -static_assert(Power>); -static_assert(!Power>); +static_assert(in_power>); +static_assert(!in_power>); -static_assert(Voltage>); -static_assert(!Voltage>); +static_assert(in_voltage>); +static_assert(!in_voltage>); -static_assert(ElectricCharge>); -static_assert(!ElectricCharge>); +static_assert(in_electric_charge>); +static_assert(!in_electric_charge>); -static_assert(Capacitance>); -static_assert(!Capacitance>); +static_assert(in_capacitance>); +static_assert(!in_capacitance>); -static_assert(SurfaceTension>); -static_assert(!SurfaceTension>); +static_assert(in_surface_tension>); +static_assert(!in_surface_tension>); -static_assert(Pressure>); -static_assert(!Pressure>); +static_assert(in_pressure>); +static_assert(!in_pressure>); -static_assert(MagneticInduction>); -static_assert(!MagneticInduction>); +static_assert(in_magnetic_induction>); +static_assert(!in_magnetic_induction>); -static_assert(MagneticFlux>); -static_assert(!MagneticFlux>); +static_assert(in_magnetic_flux>); +static_assert(!in_magnetic_flux>); -static_assert(Inductance>); -static_assert(!Inductance>); +static_assert(in_inductance>); +static_assert(!in_inductance>); -static_assert(Conductance>); -static_assert(!Conductance>); +static_assert(in_conductance>); +static_assert(!in_conductance>); // TODO Add when downcasting issue is solved // static_assert(Radioactivity>); // static_assert(!Radioactivity>); -static_assert(CatalyticActivity>); -static_assert(!CatalyticActivity>); +static_assert(in_catalytic_activity>); +static_assert(!in_catalytic_activity>); -static_assert(AbsorbedDose>); -static_assert(!AbsorbedDose>); +static_assert(in_absorbed_dose>); +static_assert(!in_absorbed_dose>); -static_assert(CurrentDensity>); -static_assert(!CurrentDensity>); +static_assert(in_current_density>); +static_assert(!in_current_density>); -static_assert(Concentration>); -static_assert(!Concentration>); +static_assert(in_concentration>); +static_assert(!in_concentration>); -static_assert(Luminance>); -static_assert(!Luminance>); +static_assert(in_luminance>); +static_assert(!in_luminance>); -static_assert(DynamicViscosity>); -static_assert(!DynamicViscosity>); +static_assert(in_dynamic_viscosity>); +static_assert(!in_dynamic_viscosity>); -static_assert(HeatCapacity>); -static_assert(!HeatCapacity>); +static_assert(in_heat_capacity>); +static_assert(!in_heat_capacity>); -static_assert(SpecificHeatCapacity>); -static_assert(!SpecificHeatCapacity>); +static_assert(in_specific_heat_capacity>); +static_assert(!in_specific_heat_capacity>); -static_assert(MolarHeatCapacity>); -static_assert(!MolarHeatCapacity>); +static_assert(in_molar_heat_capacity>); +static_assert(!in_molar_heat_capacity>); -static_assert(ThermalConductivity>); -static_assert(!ThermalConductivity>); +static_assert(in_thermal_conductivity>); +static_assert(!in_thermal_conductivity>); // TODO Add when downcasting issue is solved // static_assert(EnergyDensity>); // static_assert(!EnergyDensity>); -static_assert(ElectricFieldStrength>); -static_assert(!ElectricFieldStrength>); +static_assert(in_electric_field_strength>); +static_assert(!in_electric_field_strength>); -static_assert(ChargeDensity>); -static_assert(!ChargeDensity>); +static_assert(in_charge_density>); +static_assert(!in_charge_density>); -static_assert(SurfaceChargeDensity>); -static_assert(!SurfaceChargeDensity>); +static_assert(in_surface_charge_density>); +static_assert(!in_surface_charge_density>); -static_assert(Permittivity>); -static_assert(!Permittivity>); +static_assert(in_permittivity>); +static_assert(!in_permittivity>); -static_assert(Permeability>); -static_assert(!Permeability>); +static_assert(in_permeability>); +static_assert(!in_permeability>); -static_assert(MolarEnergy>); -static_assert(!MolarEnergy>); +static_assert(in_molar_energy>); +static_assert(!in_molar_energy>); }