Unary minus operators

Synopses

Declared in <mp‐units/utility/constrained.h>

Negates the wrapped value

Subtracts a safe_int from an integral scalar, checking for overflow.

Subtracts a safe_int from a floating‐point value.

[[nodiscard]]
constexpr
auto
operator‐(
    U lhs,
    safe_int rhs)
requires requires { lhs ‐ static_cast<U>(rhs.value_); };

Subtracts an integral scalar from a safe_int, checking for overflow.

Subtracts a floating‐point value from a safe_int.

[[nodiscard]]
constexpr
auto
operator‐(
    safe_int lhs,
    U rhs)
requires requires { static_cast<U>(lhs.value_) ‐ rhs; };

Computes the difference of lhs and rhs.

Subtracts a constrained value from a safe_int

Subtracts a non‐integral constrained value from a safe_int

Subtracts a safe_int from a constrained value

Subtracts a safe_int from a non‐integral constrained value

Return Value

  • the wrapped result of negating x

  • the difference, as a safe_int of the promoted result type; triggers ErrorPolicy::on_overflow on overflow

  • the difference between lhs and the wrapped value

  • the difference between the wrapped value and rhs

  • the result of lhs ‐ rhs; triggers ErrorPolicy::on_overflow on overflow

  • the wrapped difference of the underlying values

Note

The return value should not be discarded.

Template Parameters

Name

Description

U

the integral scalar type

Parameters

Name

Description

x

the wrapped value to negate

lhs

the integral scalar operand

rhs

the safe_int to subtract

Created with MrDocs