mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 03:14:29 +02:00
added inheritance unit-test and made is_quantity<T> more specific
This commit is contained in:
committed by
Mateusz Pusz
parent
95ac869522
commit
8e1539bf22
@@ -269,7 +269,7 @@ concept Reference = detail::is_reference<T>;
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline constexpr bool is_quantity = requires { typename T::dimension; typename T::unit; typename T::rep;};
|
inline constexpr bool is_quantity = false;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline constexpr bool is_quantity_point = false;
|
inline constexpr bool is_quantity_point = false;
|
||||||
|
@@ -460,6 +460,17 @@ namespace detail {
|
|||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
inline constexpr bool is_quantity<quantity<D, U, Rep>> = true;
|
inline constexpr bool is_quantity<quantity<D, U, Rep>> = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
requires units::is_derived_from_specialization_of<T, units::quantity> &&
|
||||||
|
requires {
|
||||||
|
typename T::dimension;
|
||||||
|
typename T::unit;
|
||||||
|
typename T::rep;
|
||||||
|
requires Dimension<typename T::dimension>;
|
||||||
|
requires Unit<typename T::unit>;
|
||||||
|
requires Representation<typename T::rep>; }
|
||||||
|
inline constexpr bool is_quantity<T> = true;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace units
|
} // namespace units
|
||||||
|
@@ -234,6 +234,18 @@ static_assert(length<kilometre, int>(2_q_km).number() == 2);
|
|||||||
static_assert(length<metre, int>(2_q_km).number() == 2000);
|
static_assert(length<metre, int>(2_q_km).number() == 2000);
|
||||||
static_assert(length<kilometre>(1500_q_m).number() == 1.5);
|
static_assert(length<kilometre>(1500_q_m).number() == 1.5);
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// derived quantities
|
||||||
|
///////////////////////////////////////
|
||||||
|
|
||||||
|
template<Representation Rep, units::Quantity Q, const units::basic_fixed_string additional_nttp_argument>
|
||||||
|
struct derived_quantity : quantity<typename Q::dimension, typename Q::unit, Rep> {
|
||||||
|
using dimension = typename Q::dimension;
|
||||||
|
using unit = typename Q::unit;
|
||||||
|
using rep = Rep;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(units::detail::is_quantity<derived_quantity<double, si::length<metre>, "NTTP type description">>);
|
||||||
|
|
||||||
/////////
|
/////////
|
||||||
// CTAD
|
// CTAD
|
||||||
|
Reference in New Issue
Block a user