A type trait that defines the behavior of scaling a value using a magnitude
<mp-units/framework/scaling.h>template<
typename From,
typename To>
struct scaling_traits
: /* implementation-defined */
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, 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 represented by value and a real number represented by M, return a value of type To representing M * value, another element of . The scaling factor M encodes the represented real value in its type.
| Name | Description |
|---|---|
/* implementation-defined */ |
| Name | Description |
|---|---|
| From | a representation type whose value is being scaled |
| To | a representation type in which the result shall be represented |