[#mp_units-value_cast-02a]
= xref:mp_units.adoc[mp&lowbar;units]::value&lowbar;cast
:relfileprefix: ../
:mrdocs:

Explicit cast of a quantity point&apos;s representation

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;framework&sol;value&lowbar;cast&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Quantity.adoc[Quantity] ToQ,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires (ToQ&colon;&colon;quantity&lowbar;spec &equals;&equals; QP&colon;&colon;quantity&lowbar;spec) &amp;&amp; UnitOf&lt;MP&lowbar;UNITS&lowbar;NONCONST&lowbar;TYPE(ToQ&colon;&colon;unit), QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
          std&colon;&colon;constructible&lowbar;from&lt;typename ToQ&colon;&colon;rep, typename QP&colon;&colon;rep&gt; &amp;&amp;
          detail&colon;&colon;SaneScaling&lt;QP&colon;&colon;unit, ToQ&colon;&colon;unit, typename ToQ&colon;&colon;rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto
value&lowbar;cast(FwdQP&& qp);
----

== Description

Implicit conversions between quantities of different types are allowed only for &quot;safe&quot; (e&period;g&period; non&hyphen;truncating) conversion&period; In truncating cases an explicit cast have to be used&period;

inline constexpr struct A &colon; absolute&lowbar;point&lowbar;origin[ A&semi;]

using ToQ &equals; quantity&lt;mm, int&gt;&semi; auto qp &equals; value&lowbar;cast&lt;ToQ&gt;(quantity&lowbar;point&lcub;1&period;23 &ast; m&rcub;)&semi;

Note that value&lowbar;cast only changes the &quot;representation aspects&quot; (unit and representation type), but not the &quot;meaning&quot; (quantity type or the actual point that is being described)&period;

== Template Parameters

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

| *ToQ*
| a target quantity type to which to cast the representation of the point
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
