A type trait that defines the behavior of scaling a value using a magnitude

Synopsis

Declared in <mp‐units/framework/scaling.h>

template<
    typename From,
    typename To>
struct scaling_traits
    : /* implementation-defined */

Description

Whereas C++ numeric types usually represent a (fixed) subset of the real numbers (or another vector‐space over the field of the real numbers), the magnitude concept fundamentally can represent any real number. Thus, in general, the result of a scaling operation is not exactly representable, and some form of approximation may be needed. That approximation is not part of the semantics of a physical quantity, but of its representation in C++. Therefore, the approximation semantics are dictated by the representation type, which can be customised for user‐types through this type‐trait.

In the following, {V} shall denote the vector‐space represented by all representation types involved in the following discussion.

A specialization scaling_traits<From, To> shall provide the following member:

  • template <auto M> static constexpr To scale(const From& value): Given an element of {V} represented by value and a real number represented by M, return a value of type To representing M * value, another element of {V}. The scaling factor M encodes the represented real value in its type.

Base Classes

Name Description

/* implementation-defined */

Template Parameters

Name Description

From

a representation type whose value is being scaled

To

a representation type in which the result shall be represented

Created with MrDocs