[#mp_units-utility-operator_minus-06]
= xref:mp_units.adoc[mp&lowbar;units]::xref:mp_units/utility.adoc[utility]::operator&hyphen;
:relfileprefix: ../../
:mrdocs:

Unary minus operators

== Synopses

Declared in `&lt;mp&hyphen;units&sol;utility&sol;constrained&period;h&gt;`

Negates the wrapped value


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/constrained.adoc[constrained&lt;decltype(&hyphen;std&colon;&colon;declval&lt;T&gt;()), ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-0d1.adoc[operator&hyphen;](xref:mp_units/utility/constrained.adoc[constrained] const& x);
----

[.small]#xref:mp_units/utility/operator_minus-0d1.adoc[_» more&period;&period;&period;_]#

Subtracts a `safe&lowbar;int` from an integral scalar, checking for overflow&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int&lt;&sol;&ast; implementation-defined &ast;&sol;, ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-02.adoc[operator&hyphen;](
    U lhs,
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] rhs);
----

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

Subtracts a `safe&lowbar;int` from a floating&hyphen;point value&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
auto
xref:mp_units/utility/operator_minus-03.adoc[operator&hyphen;](
    U lhs,
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] rhs)
requires requires &lcub; lhs &hyphen; static&lowbar;cast&lt;U&gt;(rhs&period;value&lowbar;)&semi; &rcub;;
----

[.small]#xref:mp_units/utility/operator_minus-03.adoc[_» more&period;&period;&period;_]#

Subtracts an integral scalar from a `safe&lowbar;int`, checking for overflow&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int&lt;&sol;&ast; implementation-defined &ast;&sol;, ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-0de.adoc[operator&hyphen;](
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] lhs,
    U rhs);
----

[.small]#xref:mp_units/utility/operator_minus-0de.adoc[_» more&period;&period;&period;_]#

Subtracts a floating&hyphen;point value from a `safe&lowbar;int`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
auto
xref:mp_units/utility/operator_minus-04.adoc[operator&hyphen;](
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] lhs,
    U rhs)
requires requires &lcub; static&lowbar;cast&lt;U&gt;(lhs&period;value&lowbar;) &hyphen; rhs&semi; &rcub;;
----

[.small]#xref:mp_units/utility/operator_minus-04.adoc[_» more&period;&period;&period;_]#

Computes the difference of `lhs` and `rhs&period;`


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int&lt;&sol;&ast; implementation-defined &ast;&sol;, ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-09.adoc[operator&hyphen;](
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] lhs,
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] rhs);
----

[.small]#xref:mp_units/utility/operator_minus-09.adoc[_» more&period;&period;&period;_]#

Subtracts a constrained value from a safe&lowbar;int


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int&lt;&sol;&ast; implementation-defined &ast;&sol;, ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-0b.adoc[operator&hyphen;](
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] lhs,
    xref:mp_units/utility/constrained.adoc[constrained&lt;U, CP&gt;] rhs);
----

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

Subtracts a non&hyphen;integral constrained value from a safe&lowbar;int


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/constrained.adoc[constrained&lt;decltype(std&colon;&colon;declval&lt;T&gt;() &hyphen; std&colon;&colon;declval&lt;U&gt;()), CP&gt;]
xref:mp_units/utility/operator_minus-07.adoc[operator&hyphen;](
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] lhs,
    xref:mp_units/utility/constrained.adoc[constrained&lt;U, CP&gt;] const& rhs);
----

[.small]#xref:mp_units/utility/operator_minus-07.adoc[_» more&period;&period;&period;_]#

Subtracts a safe&lowbar;int from a constrained value


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int&lt;&sol;&ast; implementation-defined &ast;&sol;, ErrorPolicy&gt;]
xref:mp_units/utility/operator_minus-05.adoc[operator&hyphen;](
    xref:mp_units/utility/constrained.adoc[constrained&lt;U, CP&gt;] lhs,
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] rhs);
----

[.small]#xref:mp_units/utility/operator_minus-05.adoc[_» more&period;&period;&period;_]#

Subtracts a safe&lowbar;int from a non&hyphen;integral constrained value


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/utility/constrained.adoc[constrained&lt;decltype(std&colon;&colon;declval&lt;U&gt;() &hyphen; std&colon;&colon;declval&lt;T&gt;()), CP&gt;]
xref:mp_units/utility/operator_minus-01.adoc[operator&hyphen;](
    xref:mp_units/utility/constrained.adoc[constrained&lt;U, CP&gt;] const& lhs,
    xref:mp_units/utility/safe_int-07.adoc[safe&lowbar;int] rhs);
----

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

== Return Value

* the wrapped result of negating `x`
* the difference, as a `safe&lowbar;int` of the promoted result type&semi; triggers `ErrorPolicy&colon;&colon;on&lowbar;overflow` on overflow
* the difference between `lhs` and the wrapped value
* the difference between the wrapped value and `rhs`
* the result of `lhs &hyphen; rhs`&semi; triggers `ErrorPolicy&colon;&colon;on&lowbar;overflow` on overflow
* the wrapped difference of the underlying values

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

[cols="1,4"]
|===
| Name| Description
| *U*
| the integral scalar type
|===

== Parameters

[cols="1,4"]
|===
| Name| Description
| *x*
| the wrapped value to negate
| *lhs*
| the integral scalar operand
| *rhs*
| the `safe&lowbar;int` to subtract
|===


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