Added the "named_deduced_unit" type and more units to the fps system

The named_deduced_unit type can be used as a named type for child for child
deduced units
This commit is contained in:
Mike Ford authored and Mateusz Pusz committed 2020-06-16 15:14:46 +02:00
1 parent 8230a42cb0
commit 5b9203d9d6
7 files changed
+130 -8

No files matched your search

+23
View File
@@ -165,6 +165,29 @@ struct deduced_unit : downcast_child<Child, detail::deduced_unit<Dim, U, URest..
using prefix_family = no_prefix;
};
/**
* @brief A unit with a deduced ratio and symbol that can be used as a named unit for children
*
* 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
* to create a deduced symbol text.
*
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
* @tparam Dim a derived dimension recipe to use for deduction
* @tparam U the unit of the first composite dimension from provided derived dimension's recipe
* @tparam URest the units for the rest of dimensions from the recipe
*/
template<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 named_deduced_unit : downcast_child<Child, detail::deduced_unit<Dim, U, URest...>> {
static constexpr bool is_named = true;
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
using prefix_family = no_prefix;
};
// template<typename Child, Dimension Dim, basic_fixed_string Symbol, PrefixFamily PF, Unit U, Unit... Us>
// struct named_deduced_derived_unit : downcast_child<Child, detail::deduced_derived_unit<Dim, U, Us...>> {
// static constexpr bool is_named = true;