diff --git a/src/core/include/mp_units/unit.h b/src/core/include/mp_units/unit.h index 9d3c353a..3de2d86f 100644 --- a/src/core/include/mp_units/unit.h +++ b/src/core/include/mp_units/unit.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -145,6 +146,22 @@ struct named_unit : std::remove_const_t { static constexpr auto symbol = Symbol; ///< Unique unit identifier }; +/** + * @brief Specialization for a unit with special name valid only for a specific quantity + * + * The same as the above but additionally limits the usage of this unit to provided quantities. + * + * @tparam Symbol a short text representation of the unit + * @tparam Unit a unit for which we provide a special name + * @tparam QuantitySpec a specification of a quantity to be measured with this unit + */ +template + requires(!Symbol.empty()) && (QS.dimension == detail::get_associated_quantity(U).dimension) +struct named_unit : std::remove_const_t { + static constexpr auto symbol = Symbol; ///< Unique unit identifier + static constexpr auto quantity_spec = QS; +}; + /** * @brief A unit of a physical constant *