[#mp_units-scaling_traits]
= xref:mp_units.adoc[mp&lowbar;units]::scaling&lowbar;traits
:relfileprefix: ../
:mrdocs:

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

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;framework&sol;scaling&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename From,
    typename To&gt;
struct scaling&lowbar;traits
    : &sol;&ast; implementation-defined &ast;&sol;
----

== Description

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

In the following, _&lcub;V&rcub;_ shall denote the vector&hyphen;space represented by all representation types involved in the following discussion&period;

A specialization `scaling&lowbar;traits&lt;From,` To&gt; shall provide the following member&colon;

* `template &lt;auto M&gt; static constexpr To scale(const From&amp; value)`&colon; Given an element of _&lcub;V&rcub;_ represented by `value` and a real number represented by `M,` return a value of type `To` representing `M &ast; value`, another element of _&lcub;V&rcub;_&period; The scaling factor `M` encodes the represented real value in its type&period;

== Base Classes

[cols="1,4"]
|===
|Name|Description

| `&sol;&ast; implementation-defined &ast;&sol;`
| 
|===

== 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]#
