Skip to content

Commit caddccd

Browse files
committed
refactor: representation_concepts.h now use new scaling abstractions
1 parent 3021b13 commit caddccd

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

src/core/include/mp-units/framework/representation_concepts.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ concept ComplexScalar = requires(const T v, const T& ref) {
205205
* @brief MagnitudeScalable
206206
*
207207
* A type is `MagnitudeScalable` if it can be scaled by a unit magnitude, i.e.
208-
* `mp_units::scaling_traits<T, T>::scale<M>(value)` is well-formed and returns something
208+
* `mp_units::scale<T>(mp_units::mag<1>, value)` is well-formed and returns something
209209
* convertible to `T`. This covers:
210210
* - the library's built-in floating-point scaling (treat_as_floating_point types),
211211
* - the library's built-in fixed-point integer scaling, and
212212
* - any user-provided `mp_units::scaling_traits<T, T>` specialization.
213213
*/
214214
template<typename T>
215215
concept MagnitudeScalable = WeaklyRegular<T> && requires(T a) {
216-
{ scaling_traits<T, T>::template scale<mp_units::mag<1>>(a) } -> std::convertible_to<T>;
216+
{ ::mp_units::scale<T>(mp_units::mag<1>, a) } -> std::convertible_to<T>;
217217
};
218218

219219
template<typename T>
@@ -295,35 +295,21 @@ namespace detail {
295295
template<typename T>
296296
constexpr bool is_quantity_like = false;
297297

298-
// `std::complex<double>` * `long double` does not work, this is why we use the `value_type` if present and correct
299-
// TODO Remove when P3788 gets accepted
300-
template<typename T>
301-
using scaling_factor_type_t = conditional<std::is_arithmetic_v<value_type_t<T>>, value_type_t<T>,
302-
conditional<treat_as_floating_point<T>, long double, std::intmax_t>>;
303-
304-
// TODO replace the below and above with the logic from #615 when available
305-
template<typename T>
306-
concept ScalableByFactor = requires(const T v, const scaling_factor_type_t<T> f) {
307-
{ v * f } -> std::common_with<T>;
308-
{ f * v } -> std::common_with<T>;
309-
{ v / f } -> std::common_with<T>;
310-
};
311-
312298
// TODO how can we use `(!Quantity<T>)` below?
313299
template<typename T>
314300
concept NotQuantity = (!is_quantity_like<T>);
315301

316302
template<typename T>
317-
concept RealScalarRepresentation = NotQuantity<T> && RealScalar<T> && ScalableByFactor<T>;
303+
concept RealScalarRepresentation = NotQuantity<T> && RealScalar<T> && MagnitudeScalable<T>;
318304

319305
template<typename T>
320-
concept ComplexScalarRepresentation = NotQuantity<T> && ComplexScalar<T> && ScalableByFactor<T>;
306+
concept ComplexScalarRepresentation = NotQuantity<T> && ComplexScalar<T> && MagnitudeScalable<T>;
321307

322308
template<typename T>
323309
concept ScalarRepresentation = RealScalarRepresentation<T> || ComplexScalarRepresentation<T>;
324310

325311
template<typename T>
326-
concept VectorRepresentation = NotQuantity<T> && Vector<T> && ScalableByFactor<T>;
312+
concept VectorRepresentation = NotQuantity<T> && Vector<T> && MagnitudeScalable<T>;
327313

328314
// template<typename T>
329315
// concept TensorRepresentation = NotQuantity<T> && Tensor<T>;

0 commit comments

Comments
 (0)