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

`value&lowbar;cast` overloads

== Synopses

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

Explicit cast of a quantity&apos;s representation


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

[.small]#xref:mp_units/value_cast-0b.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity&apos;s representation type


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename ToRep,
    typename FwdQ,
    xref:mp_units/Quantity.adoc[Quantity] Q = std::remove&lowbar;cvref&lowbar;t&lt;FwdQ&gt;&gt;
requires RepresentationOf&lt;ToRep, Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename Q&colon;&colon;rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/quantity-01.adoc[quantity&lt;Q&colon;&colon;reference, ToRep&gt;]
xref:mp_units/value_cast-0e4.adoc[value&lowbar;cast](FwdQ&& q);
----

[.small]#xref:mp_units/value_cast-0e4.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity&apos;s unit


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    auto ToU,
    typename FwdQ,
    xref:mp_units/Quantity.adoc[Quantity] Q = std::remove&lowbar;cvref&lowbar;t&lt;FwdQ&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;Q&colon;&colon;unit, ToU, typename Q&colon;&colon;rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/Quantity.adoc[Quantity] auto
xref:mp_units/value_cast-0e0.adoc[value&lowbar;cast](FwdQ&& q);
----

[.small]#xref:mp_units/value_cast-0e0.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity point&apos;s representation


[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;ExplicitlyCastable&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
xref:mp_units/value_cast-01c.adoc[value&lowbar;cast](FwdQP&& qp);
----

[.small]#xref:mp_units/value_cast-01c.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity point&apos;s representation, including potentially the point origin


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

[.small]#xref:mp_units/value_cast-0e3.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity point&apos;s representation type


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename ToRep,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires RepresentationOf&lt;ToRep, QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename QP&colon;&colon;rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/quantity_point-08.adoc[quantity&lowbar;point&lt;QP&colon;&colon;reference, QP&colon;&colon;point&lowbar;origin, ToRep&gt;]
xref:mp_units/value_cast-021.adoc[value&lowbar;cast](FwdQP&& qp);
----

[.small]#xref:mp_units/value_cast-021.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity point&apos;s unit


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] auto ToU,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;QP&colon;&colon;unit, ToU, typename QP&colon;&colon;rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto
xref:mp_units/value_cast-0d.adoc[value&lowbar;cast](FwdQP&& qp);
----

[.small]#xref:mp_units/value_cast-0d.adoc[_» more&period;&period;&period;_]#


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename ToRep,
    xref:mp_units/Unit.adoc[Unit] auto ToU,
    typename FwdQ,
    xref:mp_units/Quantity.adoc[Quantity] Q = std::remove&lowbar;cvref&lowbar;t&lt;FwdQ&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           RepresentationOf&lt;ToRep, Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename Q&colon;&colon;rep&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;Q&colon;&colon;unit, ToU, ToRep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/Quantity.adoc[Quantity] auto
xref:mp_units/value_cast-011.adoc[value&lowbar;cast](FwdQ&& q);
----

[.small]#xref:mp_units/value_cast-011.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity&apos;s unit and representation type


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] auto ToU,
    typename ToRep,
    typename FwdQ,
    xref:mp_units/Quantity.adoc[Quantity] Q = std::remove&lowbar;cvref&lowbar;t&lt;FwdQ&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           RepresentationOf&lt;ToRep, Q&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename Q&colon;&colon;rep&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;Q&colon;&colon;unit, ToU, ToRep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/Quantity.adoc[Quantity] auto
xref:mp_units/value_cast-02a.adoc[value&lowbar;cast](FwdQ&& q);
----

[.small]#xref:mp_units/value_cast-02a.adoc[_» more&period;&period;&period;_]#


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename ToRep,
    xref:mp_units/Unit.adoc[Unit] auto ToU,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           RepresentationOf&lt;ToRep, QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename QP&colon;&colon;rep&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;QP&colon;&colon;unit, ToU, ToRep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto
xref:mp_units/value_cast-01d.adoc[value&lowbar;cast](FwdQP&& qp);
----

[.small]#xref:mp_units/value_cast-01d.adoc[_» more&period;&period;&period;_]#

Explicit cast of a quantity point&apos;s unit and representation type


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] auto ToU,
    typename ToRep,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires UnitOf&lt;MP&lowbar;UNITS&lowbar;REMOVE&lowbar;CONST(decltype(ToU)), QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp;
           RepresentationOf&lt;ToRep, QP&colon;&colon;quantity&lowbar;spec&gt; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;ToRep, typename QP&colon;&colon;rep&gt; &amp;&amp;
           detail&colon;&colon;ExplicitlyCastable&lt;QP&colon;&colon;unit, ToU, ToRep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto
xref:mp_units/value_cast-033.adoc[value&lowbar;cast](FwdQP&& qp);
----

[.small]#xref:mp_units/value_cast-033.adoc[_» more&period;&period;&period;_]#

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *ToQ*
| a target quantity type to which to cast the representation
| *ToRep*
| a representation type to use for a target quantity
| *ToU*
| a unit to use for a target quantity
| *ToQP*
| a target quantity point type to which to cast the representation of the point
|===


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