refactor: *deduced_unit renamed to *derived_unit
This commit is contained in:
1 parent
6c6e7955b6
commit
8e88f06380
22 files changed
+188
-187
No files matched your search
+3
-3
@@ -80,16 +80,16 @@ template<typename... Es>
|
||||
inline constexpr int negative_exp_count = ((Es::num < 0 ? 1 : 0) + ... + 0);
|
||||
|
||||
template<typename... Us, typename... Es, std::size_t... Idxs>
|
||||
constexpr auto deduced_symbol_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
constexpr auto derived_symbol_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
{
|
||||
constexpr auto neg_exp = negative_exp_count<Es...>;
|
||||
return (exp_text<Es, Us::symbol, neg_exp, Idxs>() + ...);
|
||||
}
|
||||
|
||||
template<DerivedDimension Dim, Unit... Us>
|
||||
constexpr auto deduced_symbol_text()
|
||||
constexpr auto derived_symbol_text()
|
||||
{
|
||||
return deduced_symbol_text<Us...>(typename Dim::recipe(), std::index_sequence_for<Us...>());
|
||||
return derived_symbol_text<Us...>(typename Dim::recipe(), std::index_sequence_for<Us...>());
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
+2
-2
@@ -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> && ...);
|
||||
|
||||
// deduced_unit
|
||||
// derived_unit
|
||||
|
||||
template<Exponent E>
|
||||
constexpr ratio inverse_if_negative(const ratio& r)
|
||||
@@ -51,6 +51,6 @@ constexpr ratio derived_ratio(exponent_list<Es...>)
|
||||
}
|
||||
|
||||
template<DerivedDimension D, Unit... Us>
|
||||
using deduced_unit = scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
|
||||
using derived_unit = scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
|
||||
|
||||
} // namespace units::detail
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/deduced_symbol_text.h>
|
||||
#include <units/bits/derived_symbol_text.h>
|
||||
#include <units/bits/external/text_tools.h>
|
||||
#include <units/prefix.h>
|
||||
#include <units/derived_dimension.h>
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/deduced_symbol_text.h>
|
||||
#include <units/bits/derived_symbol_text.h>
|
||||
#include <units/bits/external/downcasting.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/deduced_unit.h>
|
||||
#include <units/bits/derived_unit.h>
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/prefix.h>
|
||||
#include <units/ratio.h>
|
||||
@@ -155,9 +155,9 @@ 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 deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = false;
|
||||
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
|
||||
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
|
||||
using prefix_family = no_prefix;
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ struct deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URes
|
||||
*
|
||||
* Defines a new unit with a deduced ratio and symbol based on the recipe from the provided
|
||||
* derived dimension. The number and order of provided units should match the recipe of the
|
||||
* derived dimension. All of the units provided should also be a named ones so it is possible
|
||||
* derived dimension. All of the units provided should also be named ones so it is possible
|
||||
* to create a deduced symbol text.
|
||||
*
|
||||
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
|
||||
@@ -179,9 +179,9 @@ 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))
|
||||
// TODO - 'noble' is placeholder to sort of mean can pass its name on to other deduced units
|
||||
struct noble_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct noble_derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = true;
|
||||
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
|
||||
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
|
||||
using prefix_family = no_prefix;
|
||||
};
|
||||
|
||||
@@ -203,7 +203,7 @@ struct noble_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U
|
||||
*/
|
||||
template<typename Child, DerivedDimension Dim, basic_symbol_text Symbol, PrefixFamily PF, Unit U, Unit... URest>
|
||||
requires detail::same_scaled_units<typename Dim::recipe, U, URest...>
|
||||
struct named_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct named_derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = true;
|
||||
static constexpr auto symbol = Symbol;
|
||||
using prefix_family = PF;
|
||||
|
||||
@@ -37,14 +37,14 @@ namespace units::isq::iec80000 {
|
||||
struct byte_per_second : unit<byte_per_second> {};
|
||||
struct dim_transfer_rate : derived_dimension<dim_transfer_rate, byte_per_second, exponent<dim_storage_capacity, 1>, exponent<si::dim_time, -1>> {};
|
||||
|
||||
struct kilobyte_per_second : deduced_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
|
||||
struct megabyte_per_second : deduced_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
|
||||
struct gigabyte_per_second : deduced_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
|
||||
struct terabyte_per_second : deduced_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
|
||||
struct petabyte_per_second : deduced_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
|
||||
struct exabyte_per_second : deduced_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
|
||||
struct zettabyte_per_second : deduced_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
|
||||
struct yottabyte_per_second : deduced_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
|
||||
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> {};
|
||||
|
||||
template<typename T>
|
||||
concept TransferRate = QuantityOf<T, dim_transfer_rate>;
|
||||
|
||||
@@ -40,7 +40,7 @@ struct foot_poundal : unit<foot_poundal> {};
|
||||
struct dim_energy : isq::dim_energy<dim_energy, foot_poundal, dim_force, dim_length> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot-pound_(energy)
|
||||
struct foot_pound_force : noble_deduced_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
struct foot_pound_force : noble_derived_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
|
||||
template<UnitOf<dim_energy> U, Representation Rep = double>
|
||||
using energy = quantity<dim_energy, U, Rep>;
|
||||
|
||||
@@ -39,7 +39,7 @@ struct foot_poundal_per_second : unit<foot_poundal_per_second> {};
|
||||
|
||||
struct dim_power : isq::dim_power<dim_power, foot_poundal_per_second, dim_energy, dim_time> {};
|
||||
|
||||
struct foot_pound_force_per_second : deduced_unit<foot_pound_force_per_second, dim_power, foot_pound_force, second> {};
|
||||
struct foot_pound_force_per_second : derived_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> {};
|
||||
|
||||
|
||||
@@ -41,10 +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 : deduced_unit<mile_per_hour, dim_speed, mile, hour>{};
|
||||
|
||||
struct nautical_mile_per_hour : named_deduced_unit<nautical_mile_per_hour, dim_speed, "knot", no_prefix, nautical_mile, hour>{};
|
||||
|
||||
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 knot : alias_unit<nautical_mile_per_hour, "knot", no_prefix> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
@@ -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 : deduced_unit<cubic_yard, dim_volume, yard> {};
|
||||
struct cubic_yard : derived_unit<cubic_yard, dim_volume, yard> {};
|
||||
|
||||
template<UnitOf<dim_volume> U, Representation Rep = double>
|
||||
using volume = quantity<dim_volume, U, Rep>;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct square_foot : deduced_unit<square_foot, si::dim_area, si::international::foot> {};
|
||||
struct square_foot : derived_unit<square_foot, si::dim_area, si::international::foot> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
|
||||
struct mile_per_hour : derived_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, si::international::foot> {};
|
||||
struct cubic_foot : derived_unit<cubic_foot, si::dim_volume, si::international::foot> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
||||
@@ -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 : deduced_unit<square_yoctometre, dim_area, yoctometre> {};
|
||||
struct square_zeptometre : deduced_unit<square_zeptometre, dim_area, zeptometre> {};
|
||||
struct square_attometre : deduced_unit<square_attometre, dim_area, attometre> {};
|
||||
struct square_femtometre : deduced_unit<square_femtometre, dim_area, femtometre> {};
|
||||
struct square_picometre : deduced_unit<square_picometre, dim_area, picometre> {};
|
||||
struct square_nanometre : deduced_unit<square_nanometre, dim_area, nanometre> {};
|
||||
struct square_micrometre : deduced_unit<square_micrometre, dim_area, micrometre> {};
|
||||
struct square_millimetre : deduced_unit<square_millimetre, dim_area, millimetre> {};
|
||||
struct square_centimetre : deduced_unit<square_centimetre, dim_area, centimetre> {};
|
||||
struct square_decimetre : deduced_unit<square_decimetre, dim_area, decimetre> {};
|
||||
struct square_decametre : deduced_unit<square_decametre, dim_area, decametre> {};
|
||||
struct square_hectometre : deduced_unit<square_hectometre, dim_area, hectometre> {};
|
||||
struct square_kilometre : deduced_unit<square_kilometre, dim_area, kilometre> {};
|
||||
struct square_megametre : deduced_unit<square_megametre, dim_area, megametre> {};
|
||||
struct square_gigametre : deduced_unit<square_gigametre, dim_area, gigametre> {};
|
||||
struct square_terametre : deduced_unit<square_terametre, dim_area, terametre> {};
|
||||
struct square_petametre : deduced_unit<square_petametre, dim_area, petametre> {};
|
||||
struct square_exametre : deduced_unit<square_exametre, dim_area, exametre> {};
|
||||
struct square_zettametre : deduced_unit<square_zettametre, dim_area, zettametre> {};
|
||||
struct square_yottametre : deduced_unit<square_yottametre, dim_area, yottametre> {};
|
||||
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 hectare : alias_unit<square_hectometre, "ha", no_prefix> {};
|
||||
|
||||
|
||||
@@ -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 : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
|
||||
template<UnitOf<dim_speed> U, Representation Rep = double>
|
||||
using speed = quantity<dim_speed, U, Rep>;
|
||||
|
||||
@@ -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 : deduced_unit<cubic_yoctometre, dim_volume, yoctometre> {};
|
||||
struct cubic_zeptometre : deduced_unit<cubic_zeptometre, dim_volume, zeptometre> {};
|
||||
struct cubic_attometre : deduced_unit<cubic_attometre, dim_volume, attometre> {};
|
||||
struct cubic_femtometre : deduced_unit<cubic_femtometre, dim_volume, femtometre> {};
|
||||
struct cubic_picometre : deduced_unit<cubic_picometre, dim_volume, picometre> {};
|
||||
struct cubic_nanometre : deduced_unit<cubic_nanometre, dim_volume, nanometre> {};
|
||||
struct cubic_micrometre : deduced_unit<cubic_micrometre, dim_volume, micrometre> {};
|
||||
struct cubic_millimetre : deduced_unit<cubic_millimetre, dim_volume, millimetre> {};
|
||||
struct cubic_centimetre : deduced_unit<cubic_centimetre, dim_volume, centimetre> {};
|
||||
struct cubic_decimetre : deduced_unit<cubic_decimetre, dim_volume, decimetre> {};
|
||||
struct cubic_decametre : deduced_unit<cubic_decametre, dim_volume, decametre> {};
|
||||
struct cubic_hectometre : deduced_unit<cubic_hectometre, dim_volume, hectometre> {};
|
||||
struct cubic_kilometre : deduced_unit<cubic_kilometre, dim_volume, kilometre> {};
|
||||
struct cubic_megametre : deduced_unit<cubic_megametre, dim_volume, megametre> {};
|
||||
struct cubic_gigametre : deduced_unit<cubic_gigametre, dim_volume, gigametre> {};
|
||||
struct cubic_terametre : deduced_unit<cubic_terametre, dim_volume, terametre> {};
|
||||
struct cubic_petametre : deduced_unit<cubic_petametre, dim_volume, petametre> {};
|
||||
struct cubic_exametre : deduced_unit<cubic_exametre, dim_volume, exametre> {};
|
||||
struct cubic_zettametre : deduced_unit<cubic_zettametre, dim_volume, zettametre> {};
|
||||
struct cubic_yottametre : deduced_unit<cubic_yottametre, dim_volume, yottametre> {};
|
||||
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 litre : alias_unit<cubic_decimetre, "l", prefix> {};
|
||||
struct yoctolitre : prefixed_alias_unit<cubic_nanometre, yocto, litre> {};
|
||||
|
||||
Reference in new issue
Block a user