[#mp_units-scaling_traits] = xref:mp_units.adoc[mp_units]::scaling_traits :relfileprefix: ../ :mrdocs: A type trait that defines the behavior of scaling a value using a magnitude == Synopsis Declared in `<mp‐units/framework/scaling.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== |Name|Description | `/* implementation-defined */` | |=== == Template Parameters [cols="1,4"] |=== |Name|Description | *From* | a representation type whose value is being scaled | *To* | a representation type in which the result shall be represented |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#