From 9a49df7222f22df308dfa1e6614932c729627af3 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 8 Sep 2020 21:17:09 +0200 Subject: [PATCH] refactor: :boom: `Scalar` concept renamed to `ScalableNumber` Resolves #114 --- docs/design/quantity.rst | 12 ++++++------ docs/framework/constants.rst | 4 ++-- docs/framework/dimensions.rst | 10 +++++----- docs/framework/quantities.rst | 9 +++++---- docs/glossary.rst | 2 +- docs/use_cases/custom_representation_types.rst | 14 +++++++------- docs/use_cases/extensions.rst | 6 +++--- docs_disabled/reference/core/concepts.rst | 2 +- example/glide_computer.cpp | 4 ++-- example/linear_algebra.cpp | 6 +++--- example/measurement.cpp | 2 +- src/include/units/bits/common_quantity.h | 6 +++--- 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/dimensionless.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/fps/acceleration.h | 2 +- src/include/units/physical/fps/area.h | 2 +- src/include/units/physical/fps/density.h | 2 +- src/include/units/physical/fps/energy.h | 2 +- src/include/units/physical/fps/force.h | 2 +- src/include/units/physical/fps/length.h | 2 +- src/include/units/physical/fps/mass.h | 2 +- src/include/units/physical/fps/power.h | 2 +- src/include/units/physical/fps/pressure.h | 2 +- src/include/units/physical/fps/speed.h | 2 +- src/include/units/physical/fps/volume.h | 2 +- src/include/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 +- .../units/physical/si/angular_velocity.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 +- src/include/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 | 16 ++++++++-------- src/include/units/quantity_cast.h | 6 +++--- src/include/units/quantity_point.h | 2 +- .../static/custom_rep_min_req_test.cpp | 10 +++++----- test/unit_test/static/custom_unit_test.cpp | 4 ++-- 88 files changed, 149 insertions(+), 148 deletions(-) diff --git a/docs/design/quantity.rst b/docs/design/quantity.rst index a027d62a..a777898c 100644 --- a/docs/design/quantity.rst +++ b/docs/design/quantity.rst @@ -11,7 +11,7 @@ Interface The difference is that it uses ``double`` as a default representation and has a few additional member types and functions:: - template U, Scalar Rep = double> + template U, ScalableNumber Rep = double> class quantity { public: using dimension = D; @@ -24,23 +24,23 @@ a few additional member types and functions:: template requires detail::basic_arithmetic && equivalent_dim> - [[nodiscard]] constexpr Scalar auto operator*(const quantity& lhs, - const quantity& rhs); + [[nodiscard]] constexpr ScalableNumber auto operator*(const quantity& lhs, + const quantity& rhs); template requires detail::basic_arithmetic && (!equivalent_dim>) [[nodiscard]] constexpr Quantity auto operator*(const quantity& lhs, const quantity& rhs); - template + template requires std::magma [[nodiscard]] constexpr Quantity auto operator/(const Value& v, const quantity& q); template requires detail::basic_arithmetic && equivalent_dim - [[nodiscard]] constexpr Scalar auto operator/(const quantity& lhs, - const quantity& rhs); + [[nodiscard]] constexpr ScalableNumber auto operator/(const quantity& lhs, + const quantity& rhs); template requires detail::basic_arithmetic && (!equivalent_dim) diff --git a/docs/framework/constants.rst b/docs/framework/constants.rst index 95336190..dfc070f3 100644 --- a/docs/framework/constants.rst +++ b/docs/framework/constants.rst @@ -18,7 +18,7 @@ For example the speed of light constant in :term:`SI` is defined as:: namespace si::si2019 { - template + template inline constexpr auto speed_of_light = speed(299792458); } @@ -27,7 +27,7 @@ The same constant defined for natural units may be provided as:: namespace natural { - template + template inline constexpr auto speed_of_light = speed(1); } diff --git a/docs/framework/dimensions.rst b/docs/framework/dimensions.rst index 017a8b3a..6fae1125 100644 --- a/docs/framework/dimensions.rst +++ b/docs/framework/dimensions.rst @@ -23,7 +23,7 @@ each other and the result will always be a quantity of the same dimension: Length auto res2 = dist1 - dist2; Additionally, we can always multiply or divide a quantity by a -:term:`scalar` and in such a case the quantity's dimension will also +:term:`scalable number` and in such a case the quantity's dimension will also not change: .. code-block:: @@ -35,7 +35,7 @@ not change: Length auto res3 = res2 / 2; // 6 m However, if we try to multiply or divide quantities of the same or -different dimensions, or we will divide a scalar by a quantity, we most +different dimensions, or we will divide a scalable number by a quantity, we most probably will always end up in a quantity of a yet another dimension: .. code-block:: @@ -50,7 +50,7 @@ probably will always end up in a quantity of a yet another dimension: However, please note that there is an exception from the above rule. In case we divide the same dimensions, or multiply by the inverted -dimension, than we will end up with just a scalar type: +dimension, than we will end up with just a scalable number type: .. code-block:: :emphasize-lines: 4-5 @@ -58,8 +58,8 @@ dimension, than we will end up with just a scalar type: Time auto dur1 = 10q_s; Time auto dur2 = 2q_s; Frequency auto fr1 = 5q_Hz; - Scalar auto v1 = dur1 / dur2; // 5 - Scalar auto v2 = dur1 * fr1; // 50 + ScalableNumber auto v1 = dur1 / dur2; // 5 + ScalableNumber auto v2 = dur1 * fr1; // 50 Quantity points have a more restricted set of operations. Quantity points can't be added together, diff --git a/docs/framework/quantities.rst b/docs/framework/quantities.rst index b5723ab8..2e2e6fd0 100644 --- a/docs/framework/quantities.rst +++ b/docs/framework/quantities.rst @@ -11,7 +11,7 @@ with a specific representation and is represented in the library with a Quantity Construction --------------------- -To create the quantity object from a :term:`scalar` we just have to pass +To create the quantity object from a :term:`scalable number` we just have to pass the value to the `quantity` class template explicit constructor:: quantity d(123); @@ -33,7 +33,7 @@ type to ``double`` by default:: namespace si { - template + template using length = quantity; } @@ -73,7 +73,8 @@ be used:: All instances of `quantity` class always match the `Quantity` concept. All other regular types that are not quantities are called - :term:`scalars ` by the library and match the `Scalar` concept. + :term:`scalable numbers ` by the library and match the + `ScalableNumber` concept. However, the above is not the most important usage of those concepts. Let's assume that the user wants to implement an ``avg_speed`` function that will @@ -183,7 +184,7 @@ are provided:: template concept Dimensionless = QuantityOf; - template + template using dimensionless = quantity; There are two special units provided for usage with such a quantity: diff --git a/docs/glossary.rst b/docs/glossary.rst index e729ad65..cc9f4def 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -198,7 +198,7 @@ Other definitions - The order and types of dimensions used in the recipe determine how an unnamed dimension's unit symbol is being printed in the text output - scalar + scalable number - Not a `quantity` - Can be passed as a representation type to the :class:`units::quantity` type or be used as a factor while multiplying or dividing a `quantity`. diff --git a/docs/use_cases/custom_representation_types.rst b/docs/use_cases/custom_representation_types.rst index f7ba006c..f650a0f3 100644 --- a/docs/use_cases/custom_representation_types.rst +++ b/docs/use_cases/custom_representation_types.rst @@ -9,11 +9,11 @@ its own custom logic for it (i.e. use a complex number or a measurement class th not only a value but also a measurement error). -A `Scalar` concept ------------------- +A `ScalableNumber` concept +-------------------------- To support a minimum set of `quantity` operations all custom representation types have to -satisfy at least the `Scalar` concept. Which means that they: +satisfy at least the `ScalableNumber` concept. Which means that they: - cannot be quantities by themselves, - cannot be wrappers over the `quantity` type (i.e. ``std::optional>``), @@ -101,8 +101,8 @@ The only difference here is that in this case we have to explicitly cast the `qu Additional Requirements ----------------------- -As noted in the previous chapter, the `Scalar` concept guarantees us the possibility to -construct quantities, convert between the units of the same dimension, and compare them +As noted in the previous chapter, the `ScalableNumber` concept guarantees us the possibility +to construct quantities, convert between the units of the same dimension, and compare them for equality. To provide additional `quantity` operations the custom representation type have to satisfy more requirements. @@ -200,7 +200,7 @@ The `quantity` class template has a few static member functions: `quantity::zero representation type. The default implementation is provided through the `quantity_values` class template:: - template + template struct quantity_values { static constexpr Rep zero() noexcept { return Rep(0); } static constexpr Rep one() noexcept { return Rep(1); } @@ -220,7 +220,7 @@ library's framework treat floating-point representation types differently than t ones. This behavior can also be extended to the custom representation types with `treat_as_floating_point` customization point which default definition is:: - template + template inline constexpr bool treat_as_floating_point = std::is_floating_point_v; If our representation type should have a floating-point semantics or if it is a class diff --git a/docs/use_cases/extensions.rst b/docs/use_cases/extensions.rst index 52ca9ffd..2df24018 100644 --- a/docs/use_cases/extensions.rst +++ b/docs/use_cases/extensions.rst @@ -121,7 +121,7 @@ coherent unit:: struct desk_per_hour : deduced_unit {}; // a quantity of our dimension - template + template using desk_rate = quantity; // a concept matching the above quantity @@ -150,7 +150,7 @@ define a new base dimension, its units, quantity helper, concept, and UDLs:: struct person : named_unit {}; struct dim_people : base_dimension<"people", person> {}; - template + template using people = quantity; template @@ -169,7 +169,7 @@ With the above we can now define a new derived dimension:: struct person_per_desk : deduced_unit {}; - template + template using occupancy_rate = quantity; template diff --git a/docs_disabled/reference/core/concepts.rst b/docs_disabled/reference/core/concepts.rst index 3debd481..747f47c9 100644 --- a/docs_disabled/reference/core/concepts.rst +++ b/docs_disabled/reference/core/concepts.rst @@ -63,7 +63,7 @@ Concepts satisfy :expr:`Quantity` recursively (i.e. :expr:`std::optional>`). -.. concept:: template Scalar +.. concept:: template ScalableNumber A concept matching non-Quantity types. Satisfied by types that match :expr:`(!Quantity) && (!WrappedQuantity) && std::regular` and satisfy one of the diff --git a/example/glide_computer.cpp b/example/glide_computer.cpp index 76f68167..36d2840e 100644 --- a/example/glide_computer.cpp +++ b/example/glide_computer.cpp @@ -87,7 +87,7 @@ public: } template - requires (Scalar || Dimensionless) + requires (ScalableNumber || Dimensionless) [[nodiscard]] friend constexpr auto operator*(const vector& lhs, const V& value) requires requires { lhs.magnitude() * value; } { @@ -95,7 +95,7 @@ public: } template - requires (Scalar || Dimensionless) + requires (ScalableNumber || Dimensionless) [[nodiscard]] friend constexpr auto operator*(const V& value, const vector& rhs) requires requires { value * rhs.magnitude(); } { diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 24a0be07..e2506fac 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -200,10 +200,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() @@ -273,7 +273,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 1237e7fc..ce1d2b73 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -114,7 +114,7 @@ private: value_type uncertainty_{}; }; -static_assert(units::Scalar>); +static_assert(units::ScalableNumber>); } // namespace diff --git a/src/include/units/bits/common_quantity.h b/src/include/units/bits/common_quantity.h index 20304e83..803dfc7c 100644 --- a/src/include/units/bits/common_quantity.h +++ b/src/include/units/bits/common_quantity.h @@ -26,10 +26,10 @@ namespace units { -template U, Scalar Rep> +template U, ScalableNumber Rep> class quantity; -template U, Scalar Rep> +template U, ScalableNumber Rep> class quantity_point; namespace detail { @@ -65,7 +65,7 @@ quantity_point common_quantity_point_impl(quantity); } // namespace detail -template> +template> requires equivalent_dim using common_quantity = TYPENAME detail::common_quantity_impl::type; diff --git a/src/include/units/concepts.h b/src/include/units/concepts.h index 43e95eed..6a6da384 100644 --- a/src/include/units/concepts.h +++ b/src/include/units/concepts.h @@ -250,7 +250,7 @@ inline constexpr bool is_wrapped_quantity = Quantity template concept WrappedQuantity = detail::is_wrapped_quantity; -// Scalar +// ScalableNumber namespace detail { @@ -280,7 +280,7 @@ concept not_constructible_from_integral = * Satisfied by types that satisfy `(!Quantity) && (!WrappedQuantity) && std::regular`. */ template -concept Scalar = +concept ScalableNumber = (!Quantity) && (!WrappedQuantity) && std::regular && diff --git a/src/include/units/customization_points.h b/src/include/units/customization_points.h index 5ff0306d..4a9f0dc2 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 13a3078d..0709cde6 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 0828f71e..9995f9c8 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/dimensionless.h b/src/include/units/dimensionless.h index 5228c63b..02e36307 100644 --- a/src/include/units/dimensionless.h +++ b/src/include/units/dimensionless.h @@ -40,7 +40,7 @@ struct dim_one : derived_dimension {}; template concept Dimensionless = QuantityOf; -template +template using dimensionless = quantity; } // namespace units diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index c3609212..7c066ad3 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 1f52edab..bd4e7f0e 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 9c290898..ef881bac 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 ec3e2d7e..9b9b8ead 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 c5d82468..11092bb7 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 1ad0456b..5079dea8 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 6a1c9c2e..a2e1d0e3 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 0c07b3dc..cadd94e3 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 5c07f202..f382daa1 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/fps/acceleration.h b/src/include/units/physical/fps/acceleration.h index 7d7ef0fb..6917dcdd 100644 --- a/src/include/units/physical/fps/acceleration.h +++ b/src/include/units/physical/fps/acceleration.h @@ -31,7 +31,7 @@ namespace units::physical::fps { struct foot_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/fps/area.h b/src/include/units/physical/fps/area.h index d5b7276e..107f053d 100644 --- a/src/include/units/physical/fps/area.h +++ b/src/include/units/physical/fps/area.h @@ -33,7 +33,7 @@ struct square_foot : unit {}; struct dim_area : physical::dim_area {}; -template +template using area = quantity; inline namespace literals { diff --git a/src/include/units/physical/fps/density.h b/src/include/units/physical/fps/density.h index 91f8d58f..118c05b5 100644 --- a/src/include/units/physical/fps/density.h +++ b/src/include/units/physical/fps/density.h @@ -33,7 +33,7 @@ struct pound_per_foot_cub : unit {}; struct dim_density : physical::dim_density {}; -template +template using density = quantity; inline namespace literals { diff --git a/src/include/units/physical/fps/energy.h b/src/include/units/physical/fps/energy.h index d3bdd14e..2d7f89d8 100644 --- a/src/include/units/physical/fps/energy.h +++ b/src/include/units/physical/fps/energy.h @@ -39,7 +39,7 @@ struct foot_pound_force : noble_deduced_unit +template using energy = quantity; diff --git a/src/include/units/physical/fps/force.h b/src/include/units/physical/fps/force.h index 47a49c16..ad6b32c3 100644 --- a/src/include/units/physical/fps/force.h +++ b/src/include/units/physical/fps/force.h @@ -43,7 +43,7 @@ struct kip : alias_unit {}; struct dim_force : physical::dim_force {}; -template +template using force = quantity; inline namespace literals { diff --git a/src/include/units/physical/fps/length.h b/src/include/units/physical/fps/length.h index d875ecd1..31f46020 100644 --- a/src/include/units/physical/fps/length.h +++ b/src/include/units/physical/fps/length.h @@ -52,7 +52,7 @@ struct nautical_mile : named_scaled_unit {}; -template +template using length = quantity; inline namespace literals { diff --git a/src/include/units/physical/fps/mass.h b/src/include/units/physical/fps/mass.h index 80787d1b..3802035f 100644 --- a/src/include/units/physical/fps/mass.h +++ b/src/include/units/physical/fps/mass.h @@ -33,7 +33,7 @@ struct pound : named_scaled_unit {}; -template +template using mass = quantity; struct grain : named_scaled_unit{}; diff --git a/src/include/units/physical/fps/power.h b/src/include/units/physical/fps/power.h index c2142e9a..6a6a320f 100644 --- a/src/include/units/physical/fps/power.h +++ b/src/include/units/physical/fps/power.h @@ -37,7 +37,7 @@ struct foot_pound_force_per_second : deduced_unit {}; -template +template using power = quantity; inline namespace literals { diff --git a/src/include/units/physical/fps/pressure.h b/src/include/units/physical/fps/pressure.h index 36f4d555..a9760bc9 100644 --- a/src/include/units/physical/fps/pressure.h +++ b/src/include/units/physical/fps/pressure.h @@ -34,7 +34,7 @@ struct poundal_per_foot_sq : unit {}; struct dim_pressure : physical::dim_pressure {}; -template +template using pressure = quantity; struct pound_force_per_foot_sq : named_scaled_unit {}; diff --git a/src/include/units/physical/fps/speed.h b/src/include/units/physical/fps/speed.h index d1512a0b..8de37c0a 100644 --- a/src/include/units/physical/fps/speed.h +++ b/src/include/units/physical/fps/speed.h @@ -32,7 +32,7 @@ namespace units::physical::fps { struct foot_per_second : unit {}; struct dim_speed : physical::dim_speed {}; -template +template using speed = quantity; struct mile_per_hour : deduced_unit{}; diff --git a/src/include/units/physical/fps/volume.h b/src/include/units/physical/fps/volume.h index 07b6f5f0..57e49c1a 100644 --- a/src/include/units/physical/fps/volume.h +++ b/src/include/units/physical/fps/volume.h @@ -33,7 +33,7 @@ struct dim_volume : physical::dim_volume {}; struct cubic_yard : deduced_unit {}; -template +template using volume = quantity; inline namespace literals { diff --git a/src/include/units/physical/natural/constants.h b/src/include/units/physical/natural/constants.h index afcb89de..20c37379 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 4ec305d5..1881f1bb 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 956c8609..9c2e88c5 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 cdb6bbc5..ca049a35 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 e3ecb480..b2114cfb 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/angular_velocity.h b/src/include/units/physical/si/angular_velocity.h index b4825355..924027dc 100644 --- a/src/include/units/physical/si/angular_velocity.h +++ b/src/include/units/physical/si/angular_velocity.h @@ -34,7 +34,7 @@ struct radian_per_second : named_unit {}; -template +template using angular_velocity = quantity; inline namespace literals { diff --git a/src/include/units/physical/si/area.h b/src/include/units/physical/si/area.h index 34fb9f4d..5b11d402 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 640da58c..3287b5fc 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 78ad7ca9..a67e9a64 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 04ba4a45..0ccad25a 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 4c6c6220..8e85b20c 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 dd7b16b4..b793d54e 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 750a1d4b..2a0e0dc0 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 b4349006..88e37efd 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 157c5cec..19fed28c 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 79407611..fa9a1707 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 412b4fe3..1a8b7dbb 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 1bdc153b..60020408 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 dead3967..0547d2a3 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 6deca407..d18fcd0e 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 835b39a9..ce60ad7c 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 c75d8213..b41f4e46 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 87897314..3911dc59 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 105a17cb..5a100fa6 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 34a881b8..c9c7e4be 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 2af847c0..1f1be254 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 0cca6300..27396f89 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 433db1ee..3d501fbb 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 441e67b2..9d631e4e 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 {} 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 c015e601..8ff950da 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 6d8b5d64..cbfd44d6 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 0e15dbf6..f8f3d6da 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 752acf04..a0bd9640 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 2f31fc26..151147ca 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 62c95239..42f62a02 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 6f68ce52..e0903d9d 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 eee8e1cb..4576b977 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 46ce7189..14f08186 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 a28f51ba..c7706edc 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 77befa13..67867061 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 cf016ebc..19fc2ddb 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 b74f0b87..ff845792 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 5c421f09..f3352295 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 {}; 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 c6fbe4d8..e5aee85d 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 b974ddfd..a0e9ee7a 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 ad5affc8..6d60139c 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 382b245d..72a5b346 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -58,7 +58,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, ScalableNumber Rep = double> class quantity { Rep value_{}; @@ -71,7 +71,7 @@ public: quantity(const quantity&) = default; quantity(quantity&&) = default; - template + template requires detail::safe_convertible constexpr explicit(!(std::is_same_v && std::is_same_v)) quantity(const Value& v) : value_{static_cast(v)} {} @@ -176,7 +176,7 @@ public: return *this; } - template + template requires (!treat_as_floating_point) && (!treat_as_floating_point) constexpr quantity& operator%=(const Value& rhs) @@ -227,7 +227,7 @@ public: return ret(ret(lhs).count() - ret(rhs).count()); } - template + template requires std::regular_invocable, Rep, Value> [[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v) { @@ -236,7 +236,7 @@ public: return ret(q.count() * v); } - template + template requires std::regular_invocable, Value, Rep> [[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q) { @@ -254,7 +254,7 @@ public: return ret(lhs.count() * rhs.count()); } - template + template requires std::regular_invocable, Value, Rep> [[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q) { @@ -267,7 +267,7 @@ public: return ret(v / q.count()); } - template + template requires std::regular_invocable, Rep, Value> [[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v) { @@ -291,7 +291,7 @@ public: return ret(lhs.count() / rhs.count()); } - template + template requires (!treat_as_floating_point) && (!treat_as_floating_point) && std::regular_invocable, Rep, Value> diff --git a/src/include/units/quantity_cast.h b/src/include/units/quantity_cast.h index d695b671..7700f05b 100644 --- a/src/include/units/quantity_cast.h +++ b/src/include/units/quantity_cast.h @@ -36,10 +36,10 @@ namespace units { -template U, Scalar Rep> +template U, ScalableNumber Rep> class quantity; -template U, Scalar Rep> +template U, ScalableNumber Rep> class quantity_point; namespace detail { @@ -374,7 +374,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/quantity_point.h b/src/include/units/quantity_point.h index 3777ef32..5de4ba09 100644 --- a/src/include/units/quantity_point.h +++ b/src/include/units/quantity_point.h @@ -37,7 +37,7 @@ namespace units { * @tparam U a measurement unit of the quantity point * @tparam Rep a type to be used to represent values of a quantity point */ -template U, Scalar Rep = double> +template U, ScalableNumber Rep = double> class quantity_point { public: using quantity_type = quantity; 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 2f50c244..37a38e69 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -86,7 +86,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::ScalableNumber>); template struct expl_constructible_impl_convertible : scalar_ops> { @@ -101,7 +101,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::ScalableNumber>); template struct impl_constructible_expl_convertible : scalar_ops> { @@ -116,7 +116,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::ScalableNumber>); template struct expl_constructible_expl_convertible : scalar_ops> { @@ -131,7 +131,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::ScalableNumber>); } // namespace @@ -170,7 +170,7 @@ using namespace units::physical::si; // constructors -// Quantity from Scalar +// Quantity from ScalableNumber // int <- int static_assert(length(expl_impl(1)).count() == 1); static_assert(!std::is_constructible_v, impl_expl>); diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index 07ebc27f..bd396f4a 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::exponent> {}; -template +template using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; struct dim_amplitude_spectral_density : derived_dimension, units::exponent> {}; -template +template using amplitude_spectral_density = quantity; }