2525// IWYU pragma: private, include <mp-units/framework.h>
2626#include < mp-units/bits/fixed_point.h>
2727#include < mp-units/framework/customization_points.h>
28+ #include < mp-units/framework/unit_magnitude_concepts.h>
2829
2930#ifndef MP_UNITS_IN_MODULE_INTERFACE
3031#ifdef MP_UNITS_IMPORT_STD
@@ -79,8 +80,8 @@ template<typename T>
7980concept UsesFloatingPointScaling =
8081 treat_as_floating_point<T> && requires (T value, floating_point_scaling_factor_type<value_type_t <T>>::type f) {
8182 // the result representation does not necessarily have to be the same.
82- { value* f } -> std::equality_comparable;
83- { value* f } -> std::copyable;
83+ { value * f } -> std::equality_comparable;
84+ { value * f } -> std::copyable;
8485 };
8586
8687template <typename T>
@@ -122,21 +123,21 @@ struct scaling_traits<From, To> {
122123 using _scaling_factor_type = std::common_type_t <value_type_t <From>, value_type_t <To>>;
123124 static_assert (std::is_floating_point_v<_scaling_factor_type>);
124125
125- template <Magnitude auto M>
126+ template <UnitMagnitude auto M>
126127 static constexpr bool implicitly_scalable =
127128 std::is_convertible_v<decltype (detail::cast_if_integral<_scaling_factor_type>(std::declval<From>()) *
128129 std::declval<_scaling_factor_type>()),
129130 To>;
130131
131- template <Magnitude auto M>
132+ template <UnitMagnitude auto M>
132133 static constexpr To scale (const From& value)
133134 {
134135 using U = _scaling_factor_type;
135- if constexpr (_is_integral (_pow <-1 >(M)) && !_is_integral (M)) {
136- constexpr U div = static_cast <U>(_get_value <long double >(_pow <-1 >(M)));
136+ if constexpr (is_integral (pow <-1 >(M)) && !is_integral (M)) {
137+ constexpr U div = static_cast <U>(get_value <long double >(pow <-1 >(M)));
137138 return static_cast <To>(detail::cast_if_integral<U>(value) / div);
138139 } else {
139- constexpr U ratio = static_cast <U>(_get_value <long double >(M));
140+ constexpr U ratio = static_cast <U>(get_value <long double >(M));
140141 return static_cast <To>(detail::cast_if_integral<U>(value) * ratio);
141142 }
142143 }
@@ -154,20 +155,20 @@ struct scaling_traits<From, To> {
154155
155156 // TODO: should we take possible overflow into account here? This would lead to this almost always resulting
156157 // in explicit conversions, except for small integral factors combined with a widening conversion.
157- template <Magnitude auto M>
158- static constexpr bool implicitly_scalable = std::is_convertible_v<From, To> && _is_integral (M);
158+ template <UnitMagnitude auto M>
159+ static constexpr bool implicitly_scalable = std::is_convertible_v<From, To> && is_integral (M);
159160
160- template <Magnitude auto M>
161+ template <UnitMagnitude auto M>
161162 static constexpr To scale (const From& value)
162163 {
163- if constexpr (_is_integral (M)) {
164- constexpr auto mul = _get_value <_common_type>(M);
164+ if constexpr (is_integral (M)) {
165+ constexpr auto mul = get_value <_common_type>(M);
165166 return static_cast <To>(static_cast <value_type_t <From>>(value) * mul);
166- } else if constexpr (_is_integral (_pow <-1 >(M))) {
167- constexpr auto div = _get_value <_common_type>(_pow <-1 >(M));
167+ } else if constexpr (is_integral (pow <-1 >(M))) {
168+ constexpr auto div = get_value <_common_type>(pow <-1 >(M));
168169 return static_cast <To>(static_cast <value_type_t <From>>(value) / div);
169170 } else {
170- constexpr auto ratio = detail::fixed_point<_common_type>(_get_value <long double >(M));
171+ constexpr auto ratio = detail::fixed_point<_common_type>(get_value <long double >(M));
171172 return static_cast <To>(ratio.scale (static_cast <value_type_t <From>>(value)));
172173 }
173174 }
@@ -181,7 +182,7 @@ MP_UNITS_EXPORT_BEGIN
181182
182183// @brief approximate the result of the symbolic multiplication of @c from by @c scaling_factor, and represent it as an
183184// instance of @to
184- template <typename To, Magnitude M, typename From>
185+ template <typename To, UnitMagnitude M, typename From>
185186 requires detail::HasScalingTraits<From, To>
186187constexpr To scale (std::type_identity<To>, M scaling_factor [[maybe_unused]], const From& value)
187188{
@@ -191,7 +192,7 @@ constexpr To scale(std::type_identity<To>, M scaling_factor [[maybe_unused]], co
191192}
192193
193194// @brief approximate the result of the symbolic multiplication of @c from by @c scaling_factor
194- template <Magnitude M, typename From>
195+ template <UnitMagnitude M, typename From>
195196 requires detail::HasScalingTraits<From, unspecified_rep>
196197constexpr auto scale (M scaling_factor [[maybe_unused]], const From& value)
197198{
0 commit comments