[#mp_units-utility-safe_int-07-2constructor-0b]
= xref:mp_units.adoc[mp&lowbar;units]::xref:mp_units/utility.adoc[utility]::xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int]::safe&lowbar;int
:relfileprefix: ../../../
:mrdocs:

Constructs a `safe&lowbar;int` from a non&hyphen;floating&hyphen;point value, checking for overflow&period;

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;utility&sol;safe&lowbar;int&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename U&gt;
requires (!treat&lowbar;as&lowbar;floating&lowbar;point&lt;std&colon;&colon;remove&lowbar;cvref&lowbar;t&lt;U&gt;&gt;) &amp;&amp; std&colon;&colon;is&lowbar;constructible&lowbar;v&lt;T, U&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
explicit(!detail&colon;&colon;is&lowbar;value&lowbar;preserving&lowbar;v&lt;std&colon;&colon;remove&lowbar;cvref&lowbar;t&lt;U&gt;, T&gt; &verbar;&verbar; !std&colon;&colon;convertible&lowbar;to&lt;U, T&gt;)
safe&lowbar;int(U const& v);
----

== Return Value

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *v*
| the value to convert from
|===


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