refactor: 💥 ! derived_unit renamed to derived_deduced_unit

This commit is contained in:
Mateusz Pusz
2022-05-11 11:23:18 +02:00
parent 8d0b643bb3
commit f5d21a0711
16 changed files with 67 additions and 65 deletions

View File

@@ -33,7 +33,7 @@ inline constexpr bool same_scaled_units = false;
template<typename... Es, Unit... Us>
inline constexpr bool same_scaled_units<exponent_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
// derived_unit
// derived_deduced_unit
template<Exponent E>
constexpr ratio inverse_if_negative(const ratio& r)
@@ -52,6 +52,7 @@ constexpr ratio derived_ratio(exponent_list<Es...>)
}
template<DerivedDimension D, Unit... Us>
using derived_unit = scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
using derived_deduced_unit =
scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
} // namespace units::detail

View File

@@ -26,7 +26,7 @@
#include <units/bits/external/downcasting.h>
// IWYU pragma: begin_exports
#include <units/bits/derived_unit.h>
#include <units/bits/derived_deduced_unit.h>
#include <units/bits/external/fixed_string.h>
#include <units/prefix.h>
#include <units/ratio.h>
@@ -155,7 +155,7 @@ struct prefixed_unit : downcast_dispatch<Child, scaled_unit<P::ratio * U::ratio,
template<typename Child, DerivedDimension Dim, Unit U, Unit... URest>
requires detail::same_scaled_units<typename Dim::recipe, U, URest...> &&
(U::is_named && (URest::is_named && ... && true))
struct derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
struct derived_deduced_unit : downcast_dispatch<Child, detail::derived_deduced_unit<Dim, U, URest...>> {
static constexpr bool is_named = false;
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
using prefix_family = no_prefix;

View File

@@ -39,14 +39,14 @@ struct dim_transfer_rate :
derived_dimension<dim_transfer_rate, byte_per_second, exponent<dim_storage_capacity, 1>,
exponent<si::dim_time, -1>> {};
struct kilobyte_per_second : derived_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
struct megabyte_per_second : derived_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
struct gigabyte_per_second : derived_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
struct terabyte_per_second : derived_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
struct petabyte_per_second : derived_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
struct exabyte_per_second : derived_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
struct zettabyte_per_second : derived_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
struct yottabyte_per_second : derived_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
struct kilobyte_per_second : derived_deduced_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
struct megabyte_per_second : derived_deduced_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
struct gigabyte_per_second : derived_deduced_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
struct terabyte_per_second : derived_deduced_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
struct petabyte_per_second : derived_deduced_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
struct exabyte_per_second : derived_deduced_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
struct zettabyte_per_second : derived_deduced_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
struct yottabyte_per_second : derived_deduced_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
template<typename T>
concept TransferRate = QuantityOf<T, dim_transfer_rate>;

View File

@@ -40,7 +40,7 @@ struct foot_poundal : unit<foot_poundal> {};
struct dim_energy : isq::dim_energy<dim_energy, foot_poundal, dim_length, dim_force> {};
// https://en.wikipedia.org/wiki/Foot-pound_(energy)
struct foot_pound_force : derived_unit<foot_pound_force, dim_energy, foot, pound_force> {};
struct foot_pound_force : derived_deduced_unit<foot_pound_force, dim_energy, foot, pound_force> {};
template<UnitOf<dim_energy> U, Representation Rep = double>
using energy = quantity<dim_energy, U, Rep>;

View File

@@ -39,7 +39,8 @@ struct foot_poundal_per_second : unit<foot_poundal_per_second> {};
struct dim_power : isq::dim_power<dim_power, foot_poundal_per_second, dim_length, dim_force, dim_time> {};
struct foot_pound_force_per_second : derived_unit<foot_pound_force_per_second, dim_power, foot, pound_force, second> {};
struct foot_pound_force_per_second :
derived_deduced_unit<foot_pound_force_per_second, dim_power, foot, pound_force, second> {};
struct horse_power : named_scaled_unit<horse_power, "hp", no_prefix, ratio(550), foot_pound_force_per_second> {};

View File

@@ -41,8 +41,8 @@ struct dim_speed : isq::dim_speed<dim_speed, foot_per_second, dim_length, dim_ti
template<UnitOf<dim_speed> U, Representation Rep = double>
using speed = quantity<dim_speed, U, Rep>;
struct mile_per_hour : derived_unit<mile_per_hour, dim_speed, mile, hour> {};
struct nautical_mile_per_hour : derived_unit<nautical_mile_per_hour, dim_speed, nautical_mile, hour> {};
struct mile_per_hour : derived_deduced_unit<mile_per_hour, dim_speed, mile, hour> {};
struct nautical_mile_per_hour : derived_deduced_unit<nautical_mile_per_hour, dim_speed, nautical_mile, hour> {};
struct knot : alias_unit<nautical_mile_per_hour, "kn", no_prefix> {};
#ifndef UNITS_NO_LITERALS

View File

@@ -37,7 +37,7 @@ namespace units::isq::si::fps {
struct cubic_foot : unit<cubic_foot> {};
struct dim_volume : isq::dim_volume<dim_volume, cubic_foot, dim_length> {};
struct cubic_yard : derived_unit<cubic_yard, dim_volume, yard> {};
struct cubic_yard : derived_deduced_unit<cubic_yard, dim_volume, yard> {};
template<UnitOf<dim_volume> U, Representation Rep = double>
using volume = quantity<dim_volume, U, Rep>;

View File

@@ -35,7 +35,7 @@
namespace units::isq::si::international {
struct square_foot : derived_unit<square_foot, si::dim_area, si::international::foot> {};
struct square_foot : derived_deduced_unit<square_foot, si::dim_area, si::international::foot> {};
#ifndef UNITS_NO_LITERALS

View File

@@ -34,9 +34,9 @@
namespace units::isq::si::international {
struct mile_per_hour : derived_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
struct mile_per_hour : derived_deduced_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
struct nautical_mile_per_hour :
derived_unit<nautical_mile_per_hour, si::dim_speed, si::international::nautical_mile, si::hour> {};
derived_deduced_unit<nautical_mile_per_hour, si::dim_speed, si::international::nautical_mile, si::hour> {};
struct knot : alias_unit<nautical_mile_per_hour, "kn", no_prefix> {};
#ifndef UNITS_NO_LITERALS

View File

@@ -35,7 +35,7 @@
namespace units::isq::si::international {
struct cubic_foot : derived_unit<cubic_foot, si::dim_volume, si::international::foot> {};
struct cubic_foot : derived_deduced_unit<cubic_foot, si::dim_volume, si::international::foot> {};
#ifndef UNITS_NO_LITERALS

View File

@@ -37,26 +37,26 @@ namespace units::isq::si {
struct square_metre : unit<square_metre> {};
struct dim_area : isq::dim_area<dim_area, square_metre, dim_length> {};
struct square_yoctometre : derived_unit<square_yoctometre, dim_area, yoctometre> {};
struct square_zeptometre : derived_unit<square_zeptometre, dim_area, zeptometre> {};
struct square_attometre : derived_unit<square_attometre, dim_area, attometre> {};
struct square_femtometre : derived_unit<square_femtometre, dim_area, femtometre> {};
struct square_picometre : derived_unit<square_picometre, dim_area, picometre> {};
struct square_nanometre : derived_unit<square_nanometre, dim_area, nanometre> {};
struct square_micrometre : derived_unit<square_micrometre, dim_area, micrometre> {};
struct square_millimetre : derived_unit<square_millimetre, dim_area, millimetre> {};
struct square_centimetre : derived_unit<square_centimetre, dim_area, centimetre> {};
struct square_decimetre : derived_unit<square_decimetre, dim_area, decimetre> {};
struct square_decametre : derived_unit<square_decametre, dim_area, decametre> {};
struct square_hectometre : derived_unit<square_hectometre, dim_area, hectometre> {};
struct square_kilometre : derived_unit<square_kilometre, dim_area, kilometre> {};
struct square_megametre : derived_unit<square_megametre, dim_area, megametre> {};
struct square_gigametre : derived_unit<square_gigametre, dim_area, gigametre> {};
struct square_terametre : derived_unit<square_terametre, dim_area, terametre> {};
struct square_petametre : derived_unit<square_petametre, dim_area, petametre> {};
struct square_exametre : derived_unit<square_exametre, dim_area, exametre> {};
struct square_zettametre : derived_unit<square_zettametre, dim_area, zettametre> {};
struct square_yottametre : derived_unit<square_yottametre, dim_area, yottametre> {};
struct square_yoctometre : derived_deduced_unit<square_yoctometre, dim_area, yoctometre> {};
struct square_zeptometre : derived_deduced_unit<square_zeptometre, dim_area, zeptometre> {};
struct square_attometre : derived_deduced_unit<square_attometre, dim_area, attometre> {};
struct square_femtometre : derived_deduced_unit<square_femtometre, dim_area, femtometre> {};
struct square_picometre : derived_deduced_unit<square_picometre, dim_area, picometre> {};
struct square_nanometre : derived_deduced_unit<square_nanometre, dim_area, nanometre> {};
struct square_micrometre : derived_deduced_unit<square_micrometre, dim_area, micrometre> {};
struct square_millimetre : derived_deduced_unit<square_millimetre, dim_area, millimetre> {};
struct square_centimetre : derived_deduced_unit<square_centimetre, dim_area, centimetre> {};
struct square_decimetre : derived_deduced_unit<square_decimetre, dim_area, decimetre> {};
struct square_decametre : derived_deduced_unit<square_decametre, dim_area, decametre> {};
struct square_hectometre : derived_deduced_unit<square_hectometre, dim_area, hectometre> {};
struct square_kilometre : derived_deduced_unit<square_kilometre, dim_area, kilometre> {};
struct square_megametre : derived_deduced_unit<square_megametre, dim_area, megametre> {};
struct square_gigametre : derived_deduced_unit<square_gigametre, dim_area, gigametre> {};
struct square_terametre : derived_deduced_unit<square_terametre, dim_area, terametre> {};
struct square_petametre : derived_deduced_unit<square_petametre, dim_area, petametre> {};
struct square_exametre : derived_deduced_unit<square_exametre, dim_area, exametre> {};
struct square_zettametre : derived_deduced_unit<square_zettametre, dim_area, zettametre> {};
struct square_yottametre : derived_deduced_unit<square_yottametre, dim_area, yottametre> {};
struct are : alias_unit<square_decametre, "a", prefix> {};
struct centiare : prefixed_alias_unit<square_metre, centi, are> {};

View File

@@ -37,7 +37,7 @@ namespace units::isq::si {
struct metre_per_second : unit<metre_per_second> {};
struct dim_speed : isq::dim_speed<dim_speed, metre_per_second, dim_length, dim_time> {};
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
struct kilometre_per_hour : derived_deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
template<UnitOf<dim_speed> U, Representation Rep = double>
using speed = quantity<dim_speed, U, Rep>;

View File

@@ -37,26 +37,26 @@ namespace units::isq::si {
struct cubic_metre : unit<cubic_metre> {};
struct dim_volume : isq::dim_volume<dim_volume, cubic_metre, dim_length> {};
struct cubic_yoctometre : derived_unit<cubic_yoctometre, dim_volume, yoctometre> {};
struct cubic_zeptometre : derived_unit<cubic_zeptometre, dim_volume, zeptometre> {};
struct cubic_attometre : derived_unit<cubic_attometre, dim_volume, attometre> {};
struct cubic_femtometre : derived_unit<cubic_femtometre, dim_volume, femtometre> {};
struct cubic_picometre : derived_unit<cubic_picometre, dim_volume, picometre> {};
struct cubic_nanometre : derived_unit<cubic_nanometre, dim_volume, nanometre> {};
struct cubic_micrometre : derived_unit<cubic_micrometre, dim_volume, micrometre> {};
struct cubic_millimetre : derived_unit<cubic_millimetre, dim_volume, millimetre> {};
struct cubic_centimetre : derived_unit<cubic_centimetre, dim_volume, centimetre> {};
struct cubic_decimetre : derived_unit<cubic_decimetre, dim_volume, decimetre> {};
struct cubic_decametre : derived_unit<cubic_decametre, dim_volume, decametre> {};
struct cubic_hectometre : derived_unit<cubic_hectometre, dim_volume, hectometre> {};
struct cubic_kilometre : derived_unit<cubic_kilometre, dim_volume, kilometre> {};
struct cubic_megametre : derived_unit<cubic_megametre, dim_volume, megametre> {};
struct cubic_gigametre : derived_unit<cubic_gigametre, dim_volume, gigametre> {};
struct cubic_terametre : derived_unit<cubic_terametre, dim_volume, terametre> {};
struct cubic_petametre : derived_unit<cubic_petametre, dim_volume, petametre> {};
struct cubic_exametre : derived_unit<cubic_exametre, dim_volume, exametre> {};
struct cubic_zettametre : derived_unit<cubic_zettametre, dim_volume, zettametre> {};
struct cubic_yottametre : derived_unit<cubic_yottametre, dim_volume, yottametre> {};
struct cubic_yoctometre : derived_deduced_unit<cubic_yoctometre, dim_volume, yoctometre> {};
struct cubic_zeptometre : derived_deduced_unit<cubic_zeptometre, dim_volume, zeptometre> {};
struct cubic_attometre : derived_deduced_unit<cubic_attometre, dim_volume, attometre> {};
struct cubic_femtometre : derived_deduced_unit<cubic_femtometre, dim_volume, femtometre> {};
struct cubic_picometre : derived_deduced_unit<cubic_picometre, dim_volume, picometre> {};
struct cubic_nanometre : derived_deduced_unit<cubic_nanometre, dim_volume, nanometre> {};
struct cubic_micrometre : derived_deduced_unit<cubic_micrometre, dim_volume, micrometre> {};
struct cubic_millimetre : derived_deduced_unit<cubic_millimetre, dim_volume, millimetre> {};
struct cubic_centimetre : derived_deduced_unit<cubic_centimetre, dim_volume, centimetre> {};
struct cubic_decimetre : derived_deduced_unit<cubic_decimetre, dim_volume, decimetre> {};
struct cubic_decametre : derived_deduced_unit<cubic_decametre, dim_volume, decametre> {};
struct cubic_hectometre : derived_deduced_unit<cubic_hectometre, dim_volume, hectometre> {};
struct cubic_kilometre : derived_deduced_unit<cubic_kilometre, dim_volume, kilometre> {};
struct cubic_megametre : derived_deduced_unit<cubic_megametre, dim_volume, megametre> {};
struct cubic_gigametre : derived_deduced_unit<cubic_gigametre, dim_volume, gigametre> {};
struct cubic_terametre : derived_deduced_unit<cubic_terametre, dim_volume, terametre> {};
struct cubic_petametre : derived_deduced_unit<cubic_petametre, dim_volume, petametre> {};
struct cubic_exametre : derived_deduced_unit<cubic_exametre, dim_volume, exametre> {};
struct cubic_zettametre : derived_deduced_unit<cubic_zettametre, dim_volume, zettametre> {};
struct cubic_yottametre : derived_deduced_unit<cubic_yottametre, dim_volume, yottametre> {};
struct litre : alias_unit<cubic_decimetre, "l", prefix> {};
struct yoctolitre : prefixed_alias_unit<cubic_nanometre, yocto, litre> {};

View File

@@ -189,7 +189,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
SECTION("surface tension")
{
struct newton_per_centimetre :
derived_unit<newton_per_centimetre, si::dim_surface_tension, newton, centimetre> {};
derived_deduced_unit<newton_per_centimetre, si::dim_surface_tension, newton, centimetre> {};
const surface_tension<newton_per_centimetre> q(123);
os << q;

View File

@@ -73,7 +73,7 @@ struct kilogram_per_second : unit<kilogram_per_second> {};
struct dim_mass_rate :
derived_dimension<dim_mass_rate, kilogram_per_second, units::exponent<dim_mass, 1>, units::exponent<dim_time, -1>> {
};
struct kilogram_per_hour : derived_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
struct kilogram_per_hour : derived_deduced_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
[[maybe_unused]] constexpr auto a = 1_q_kg / 1_q_h;
} // namespace

View File

@@ -55,7 +55,7 @@ static_assert([]<Prefix P>(P) {
struct metre_per_second : unit<metre_per_second> {};
struct dim_speed :
derived_dimension<dim_speed, metre_per_second, units::exponent<dim_length, 1>, units::exponent<dim_time, -1>> {};
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
struct kilometre_per_hour : derived_deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
static_assert(equivalent<metre::named_unit, metre>);
static_assert(equivalent<metre::scaled_unit, metre>);