removed base_prefix_family from unit classes, added PrefixFamily template argument to alias_unit

This commit is contained in:
Ramzi Sabra
2020-05-07 21:49:20 +03:00
committed by Mateusz Pusz
parent 17ce8d3dc8
commit 2f6ecb113a
4 changed files with 6 additions and 13 deletions

View File

@@ -52,7 +52,7 @@ struct square_exametre : deduced_unit<square_exametre, dim_area, exametre> {};
struct square_zettametre : deduced_unit<square_zettametre, dim_area, zettametre> {}; struct square_zettametre : deduced_unit<square_zettametre, dim_area, zettametre> {};
struct square_yottametre : deduced_unit<square_yottametre, dim_area, yottametre> {}; struct square_yottametre : deduced_unit<square_yottametre, dim_area, yottametre> {};
struct hectare : alias_unit<square_hectometre, "ha"> {}; struct hectare : alias_unit<square_hectometre, "ha", no_prefix> {};
template<Unit U, Scalar Rep = double> template<Unit U, Scalar Rep = double>
using area = quantity<dim_area, U, Rep>; using area = quantity<dim_area, U, Rep>;

View File

@@ -50,7 +50,7 @@ struct exagram : prefixed_unit<exagram, exa, gram> {};
struct zettagram : prefixed_unit<zettagram, zetta, gram> {}; struct zettagram : prefixed_unit<zettagram, zetta, gram> {};
struct yottagram : prefixed_unit<yottagram, yotta, gram> {}; struct yottagram : prefixed_unit<yottagram, yotta, gram> {};
struct tonne : alias_unit<megagram, "t"> {}; struct tonne : alias_unit<megagram, "t", prefix> {};
struct yoctotonne : prefixed_alias_unit<attogram, yocto, tonne> {}; struct yoctotonne : prefixed_alias_unit<attogram, yocto, tonne> {};
struct zeptotonne : prefixed_alias_unit<femtogram, zepto, tonne> {}; struct zeptotonne : prefixed_alias_unit<femtogram, zepto, tonne> {};
struct attotonne : prefixed_alias_unit<picogram, atto, tonne> {}; struct attotonne : prefixed_alias_unit<picogram, atto, tonne> {};

View File

@@ -52,7 +52,7 @@ struct cubic_exametre : deduced_unit<cubic_exametre, dim_volume, exametre> {};
struct cubic_zettametre : deduced_unit<cubic_zettametre, dim_volume, zettametre> {}; struct cubic_zettametre : deduced_unit<cubic_zettametre, dim_volume, zettametre> {};
struct cubic_yottametre : deduced_unit<cubic_yottametre, dim_volume, yottametre> {}; struct cubic_yottametre : deduced_unit<cubic_yottametre, dim_volume, yottametre> {};
struct litre : alias_unit<cubic_decimetre, "l"> {}; struct litre : alias_unit<cubic_decimetre, "l", prefix> {};
struct yoctolitre : prefixed_alias_unit<cubic_nanometre, yocto, litre> {}; struct yoctolitre : prefixed_alias_unit<cubic_nanometre, yocto, litre> {};
struct zeptolitre : prefixed_unit<zeptolitre, zepto, litre> {}; struct zeptolitre : prefixed_unit<zeptolitre, zepto, litre> {};
struct attolitre : prefixed_unit<attolitre, atto, litre> {}; struct attolitre : prefixed_unit<attolitre, atto, litre> {};

View File

@@ -74,7 +74,6 @@ template<typename Child>
struct unit : downcast_child<Child, scaled_unit<ratio<1>, Child>> { struct unit : downcast_child<Child, scaled_unit<ratio<1>, Child>> {
static constexpr bool is_named = false; static constexpr bool is_named = false;
using prefix_family = no_prefix; using prefix_family = no_prefix;
using base_prefix_family = no_prefix;
}; };
/** /**
@@ -101,7 +100,6 @@ struct named_unit : downcast_child<Child, scaled_unit<ratio<1>, Child>> {
static constexpr bool is_named = true; static constexpr bool is_named = true;
static constexpr auto symbol = Symbol; static constexpr auto symbol = Symbol;
using prefix_family = PT; using prefix_family = PT;
using base_prefix_family = PT;
}; };
/** /**
@@ -123,7 +121,6 @@ struct named_scaled_unit : downcast_child<Child, scaled_unit<ratio_multiply<R, t
static constexpr bool is_named = true; static constexpr bool is_named = true;
static constexpr auto symbol = Symbol; static constexpr auto symbol = Symbol;
using prefix_family = PT; using prefix_family = PT;
using base_prefix_family = PT;
}; };
/** /**
@@ -144,7 +141,6 @@ struct prefixed_unit :
static constexpr bool is_named = true; static constexpr bool is_named = true;
static constexpr auto symbol = P::symbol + U::symbol; static constexpr auto symbol = P::symbol + U::symbol;
using prefix_family = no_prefix; using prefix_family = no_prefix;
using base_prefix_family = U::base_prefix_family;
}; };
/** /**
@@ -167,7 +163,6 @@ struct deduced_unit : downcast_child<Child, detail::deduced_unit<Dim, U, URest..
static constexpr bool is_named = false; static constexpr bool is_named = false;
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>(); static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
using prefix_family = no_prefix; using prefix_family = no_prefix;
using base_prefix_family = U::base_prefix_family;
}; };
// template<typename Child, Dimension Dim, basic_fixed_string Symbol, PrefixFamily PT, Unit U, Unit... Us> // template<typename Child, Dimension Dim, basic_fixed_string Symbol, PrefixFamily PT, Unit U, Unit... Us>
@@ -177,20 +172,18 @@ struct deduced_unit : downcast_child<Child, detail::deduced_unit<Dim, U, URest..
// using prefix_family = PT; // using prefix_family = PT;
// }; // };
template<Unit U, basic_symbol_text Symbol> template<Unit U, basic_symbol_text Symbol, PrefixFamily PT>
struct alias_unit : U { struct alias_unit : U {
static constexpr bool is_named = true; static constexpr bool is_named = true;
static constexpr auto symbol = Symbol; static constexpr auto symbol = Symbol;
using prefix_family = U::base_prefix_family; using prefix_family = PT;
using base_prefix_family = U::base_prefix_family;
}; };
template<Unit U, Prefix P, Unit AU> template<Unit U, Prefix P, Unit AU>
struct prefixed_alias_unit : U { struct prefixed_alias_unit : U {
static constexpr bool is_named = true; static constexpr bool is_named = true;
static constexpr auto symbol = P::symbol + AU::symbol; static constexpr auto symbol = P::symbol + AU::symbol;
using prefix_family = no_prefix; using prefix_family = AU::prefix_family;
using base_prefix_family = AU::base_prefix_family;
}; };
} // namespace units } // namespace units