From 110a56dc3072c784142a2f4914d65844828a04f8 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 28 Apr 2025 15:23:36 +0200 Subject: [PATCH] feat: `is_value_preserving` customization point added --- .../mp-units/framework/customization_points.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/include/mp-units/framework/customization_points.h b/src/core/include/mp-units/framework/customization_points.h index 430f7b9e..23bf4be7 100644 --- a/src/core/include/mp-units/framework/customization_points.h +++ b/src/core/include/mp-units/framework/customization_points.h @@ -60,6 +60,19 @@ constexpr bool treat_as_floating_point = std::is_floating_point_v>; #endif +/** + * @brief Specifies if a specific conversion between two types preserves the value + * + * This type trait should be specialized for a custom representation types to specify + * weather the conversion from the source type to the destination type preserves the value + * or not. Value-truncating conversions should be forced by the user with explicit casts. + * + * @tparam From a source representation type + * @tparam To a destination representation type + */ +template +constexpr bool is_value_preserving = treat_as_floating_point || !treat_as_floating_point; + template [[deprecated("2.5.0: `is_scalar` is no longer necessary and can simply be removed")]] constexpr bool is_scalar = false;