|
26 | 26 | #include <mp-units/bits/hacks.h> |
27 | 27 | #include <mp-units/bits/module_macros.h> |
28 | 28 | #include <mp-units/bits/sudo_cast.h> |
| 29 | +#include <mp-units/bits/unsatisfied.h> |
29 | 30 | #include <mp-units/compat_macros.h> |
30 | 31 | #include <mp-units/framework/customization_points.h> |
31 | 32 | #include <mp-units/framework/dimension_concepts.h> |
@@ -76,16 +77,21 @@ template<typename T, typename Arg> |
76 | 77 | concept ValuePreservingAssignment = std::assignable_from<T&, Arg> && is_value_preserving<std::remove_cvref_t<Arg>, T>; |
77 | 78 |
|
78 | 79 | template<auto FromUnit, auto ToUnit, typename Rep> |
79 | | -concept ValuePreservingScaling1Rep = SaneScaling<FromUnit, ToUnit, Rep> && |
80 | | - (treat_as_floating_point<Rep> || (integral_conversion_factor(FromUnit, ToUnit))); |
| 80 | +concept ValuePreservingScaling1Rep = |
| 81 | + SaneScaling<FromUnit, ToUnit, Rep> && |
| 82 | + (treat_as_floating_point<Rep> || (integral_conversion_factor(FromUnit, ToUnit)) || |
| 83 | + unsatisfied<"Scaling from '{}' to '{}' is not value-preserving for '{}' representation type">( |
| 84 | + unit_symbol(FromUnit), unit_symbol(ToUnit), type_name<Rep>())); |
81 | 85 |
|
82 | 86 | template<auto FromUnit, typename FromRep, auto ToUnit, typename ToRep> |
83 | 87 | concept ValuePreservingScaling2Reps = |
84 | 88 | // TODO consider providing constraints of sudo_cast to check if representation types can be scaled between each other |
85 | 89 | // CastableReps<FromRep, ToRep, FromUnit, ToUnit> && |
86 | 90 | SaneScaling<FromUnit, ToUnit, ToRep> && |
87 | 91 | (treat_as_floating_point<ToRep> || |
88 | | - (!treat_as_floating_point<FromRep> && integral_conversion_factor(FromUnit, ToUnit))); |
| 92 | + (!treat_as_floating_point<FromRep> && integral_conversion_factor(FromUnit, ToUnit)) || |
| 93 | + unsatisfied<"Scaling from '{}' as '{}' to '{}' as '{}' is not value-preserving">( |
| 94 | + unit_symbol(FromUnit), type_name<FromRep>(), unit_symbol(ToUnit), type_name<ToRep>())); |
89 | 95 |
|
90 | 96 | template<typename QTo, typename QFrom> |
91 | 97 | concept QuantityConstructibleFrom = |
|
0 commit comments