forked from mpusz/mp-units
feat: DerivedQuantitySpecExpr
and DerivedUnitExpr
removed
This commit is contained in:
@@ -429,7 +429,10 @@ struct quantity_spec<Self, QS, Eq, Args...> : detail::quantity_spec_interface<Se
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<detail::DerivedQuantitySpecExpr... Expr>
|
||||
template<typename T>
|
||||
struct is_dimensionless : std::false_type {};
|
||||
|
||||
template<typename... Expr>
|
||||
struct derived_quantity_spec_impl :
|
||||
#if MP_UNITS_API_NO_CRTP
|
||||
detail::quantity_spec_interface,
|
||||
@@ -492,7 +495,7 @@ struct derived_quantity_spec_impl :
|
||||
* @note User should not instantiate this type! It is not exported from the C++ module. The library will
|
||||
* instantiate this type automatically based on the dimensional arithmetic equation provided by the user.
|
||||
*/
|
||||
template<detail::DerivedQuantitySpecExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_quantity_spec final : detail::derived_quantity_spec_impl<Expr...> {};
|
||||
|
||||
/**
|
||||
|
@@ -76,28 +76,9 @@ template<typename T>
|
||||
concept NamedQuantitySpec =
|
||||
QuantitySpec<T> && is_derived_from_specialization_of_quantity_spec<T> && (!QuantityKindSpec<T>);
|
||||
|
||||
template<typename T>
|
||||
struct is_dimensionless : std::false_type {};
|
||||
|
||||
template<typename T>
|
||||
concept IsPowerOfQuantitySpec = is_specialization_of_power<T> &&
|
||||
(NamedQuantitySpec<typename T::factor> || is_dimensionless<typename T::factor>::value);
|
||||
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_per_of_quantity_specs = false;
|
||||
|
||||
template<typename... Ts>
|
||||
constexpr bool is_per_of_quantity_specs<per<Ts...>> =
|
||||
(... && (NamedQuantitySpec<Ts> || is_dimensionless<Ts>::value || IsPowerOfQuantitySpec<Ts>));
|
||||
|
||||
template<typename T>
|
||||
concept DerivedQuantitySpecExpr = detail::NamedQuantitySpec<T> || detail::is_dimensionless<T>::value ||
|
||||
detail::IsPowerOfQuantitySpec<T> || detail::is_per_of_quantity_specs<T>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<detail::DerivedQuantitySpecExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_quantity_spec;
|
||||
|
||||
namespace detail {
|
||||
|
@@ -67,7 +67,7 @@ struct scaled_unit_impl;
|
||||
template<typename T>
|
||||
constexpr bool is_specialization_of_scaled_unit = false;
|
||||
|
||||
template<DerivedUnitExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_unit_impl;
|
||||
|
||||
/**
|
||||
@@ -461,7 +461,7 @@ namespace detail {
|
||||
template<typename T>
|
||||
struct is_one : std::false_type {};
|
||||
|
||||
template<DerivedUnitExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_unit_impl : detail::unit_interface, detail::expr_fractions<detail::is_one, Expr...> {
|
||||
using _base_type_ = derived_unit_impl; // exposition only
|
||||
};
|
||||
@@ -513,7 +513,7 @@ struct derived_unit_impl : detail::unit_interface, detail::expr_fractions<detail
|
||||
* @note User should not instantiate this type! It is not exported from the C++ module. The library will
|
||||
* instantiate this type automatically based on the unit arithmetic equation provided by the user.
|
||||
*/
|
||||
template<detail::DerivedUnitExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_unit final : detail::derived_unit_impl<Expr...> {};
|
||||
|
||||
/**
|
||||
@@ -831,13 +831,13 @@ constexpr auto unit_symbol_impl(Out out, const power<F, Num, Den...>&, const uni
|
||||
return copy_symbol_exponent<CharT, Num, Den...>(fmt.encoding, negative_power, out);
|
||||
}
|
||||
|
||||
template<typename CharT, std::output_iterator<CharT> Out, DerivedUnitExpr... Us>
|
||||
template<typename CharT, std::output_iterator<CharT> Out, typename... Us>
|
||||
constexpr Out unit_symbol_impl(Out out, const type_list<>&, const unit_symbol_formatting&, bool)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename CharT, std::output_iterator<CharT> Out, DerivedUnitExpr U, DerivedUnitExpr... Rest>
|
||||
template<typename CharT, std::output_iterator<CharT> Out, typename U, typename... Rest>
|
||||
constexpr Out unit_symbol_impl(Out out, const type_list<U, Rest...>&, const unit_symbol_formatting& fmt,
|
||||
bool negative_power)
|
||||
{
|
||||
@@ -845,7 +845,7 @@ constexpr Out unit_symbol_impl(Out out, const type_list<U, Rest...>&, const unit
|
||||
(print_separator<CharT>(out, fmt), out = unit_symbol_impl<CharT>(out, Rest{}, fmt, negative_power)));
|
||||
}
|
||||
|
||||
template<typename CharT, std::output_iterator<CharT> Out, DerivedUnitExpr... Nums, DerivedUnitExpr... Dens>
|
||||
template<typename CharT, std::output_iterator<CharT> Out, typename... Nums, typename... Dens>
|
||||
constexpr Out unit_symbol_impl(Out out, const type_list<Nums...>& nums, const type_list<Dens...>& dens,
|
||||
const unit_symbol_formatting& fmt)
|
||||
{
|
||||
|
@@ -60,23 +60,7 @@ MP_UNITS_EXPORT struct one;
|
||||
MP_UNITS_EXPORT template<typename T>
|
||||
concept PrefixableUnit = Unit<T> && is_derived_from_specialization_of_v<T, named_unit>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_power_of_unit = requires { requires is_specialization_of_power<T> && Unit<typename T::factor>; };
|
||||
|
||||
template<typename T>
|
||||
constexpr bool is_per_of_units = false;
|
||||
|
||||
template<typename... Ts>
|
||||
constexpr bool is_per_of_units<per<Ts...>> = (... && (Unit<Ts> || is_power_of_unit<Ts>));
|
||||
|
||||
template<typename T>
|
||||
concept DerivedUnitExpr = Unit<T> || detail::is_power_of_unit<T> || detail::is_per_of_units<T>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<detail::DerivedUnitExpr... Expr>
|
||||
template<typename... Expr>
|
||||
struct derived_unit;
|
||||
|
||||
MP_UNITS_EXPORT template<symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
||||
|
Reference in New Issue
Block a user