mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
fix: relative_point_origin::quantity_spec
setting fixed
This commit is contained in:
@@ -29,16 +29,21 @@
|
||||
|
||||
namespace mp_units {
|
||||
|
||||
template<QuantitySpec auto Q>
|
||||
template<QuantitySpec auto QS>
|
||||
struct absolute_point_origin {
|
||||
static constexpr QuantitySpec auto quantity_spec = Q;
|
||||
static constexpr QuantitySpec auto quantity_spec = QS;
|
||||
};
|
||||
|
||||
template<QuantityPoint auto QP>
|
||||
struct relative_point_origin {
|
||||
static constexpr QuantityPoint auto quantity_point = QP;
|
||||
static constexpr QuantitySpec auto quantity_spec =
|
||||
common_quantity_spec(QP.quantity_spec, QP.point_origin.quantity_spec);
|
||||
static constexpr QuantitySpec auto quantity_spec = [](){
|
||||
// select the strongest of specs
|
||||
if constexpr (detail::QuantityKindSpec<std::remove_const_t<decltype(QP.quantity_spec)>>)
|
||||
return QP.point_origin.quantity_spec;
|
||||
else
|
||||
return QP.quantity_spec;
|
||||
}();
|
||||
static constexpr PointOrigin auto absolute_point_origin = QP.absolute_point_origin;
|
||||
};
|
||||
|
||||
|
@@ -1156,5 +1156,22 @@ static_assert(invalid_addition(5 * activity[Bq], 10 / (2 * isq::time[s]), zero_H
|
||||
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// relative point origin
|
||||
/////////////////////////
|
||||
|
||||
template<auto QS>
|
||||
struct absolute_po_ : absolute_point_origin<QS> {};
|
||||
template<auto QS>
|
||||
inline constexpr absolute_po_<QS> absolute_po;
|
||||
|
||||
template<auto QP>
|
||||
struct relative_po_ : relative_point_origin<QP> {};
|
||||
template<auto QP>
|
||||
inline constexpr relative_po_<QP> relative_po;
|
||||
|
||||
static_assert(relative_po<absolute_po<isq::length> + isq::height(42 * m)>.quantity_spec == isq::height);
|
||||
static_assert(relative_po<absolute_po<kind_of<isq::length>> + isq::height(42 * m)>.quantity_spec == isq::height);
|
||||
static_assert(relative_po<absolute_po<isq::height> + 42 * m>.quantity_spec == isq::height);
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user