[#mp_units-quantity_cast-08]
= xref:mp_units.adoc[mp&lowbar;units]::quantity&lowbar;cast
:relfileprefix: ../
:mrdocs:

Explicit cast of a quantity point type

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/QuantitySpec.adoc[QuantitySpec] auto ToQS,
    typename FwdQP,
    xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove&lowbar;cvref&lowbar;t&lt;FwdQP&gt;&gt;
requires (castable(QP&colon;&colon;quantity&lowbar;spec, ToQS)) &amp;&amp; (MP&lowbar;UNITS&lowbar;WEAK&lowbar;UNIT&lowbar;OF(MP&lowbar;UNITS&lowbar;NONCONST&lowbar;TYPE(QP&colon;&colon;unit), ToQS))
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto
quantity&lowbar;cast(FwdQP&& qp);
----

== Description

This cast converts only a quantity point type&period; It might be used to force some quantity point type conversions that are not implicitly allowed but are allowed explicitly&period;

For example&colon;

[,cpp]
----
{.cpp}
 auto length = isq::length(quantity_point{42 * m});
 auto altitude = quantity_cast<isq::altitude>(length);
----
[NOTE]
====
This cast does not affect the underlying value of a number stored in a quantity point&period;

====

== Template Parameters

[cols=2]
|===
| Name
| Description
| *ToQS*
| a quantity specification to use for a target quantity point
|===


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