mp_units::utility::operator%

Modulus operators

Synopses

Declared in <mp-units/utility/safe_int.h>

Computes the remainder of dividing an integral scalar by a safe_int.

[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator%(
    U lhs,
    safe_int rhs);
» more...

Computes the remainder of dividing a safe_int by an integral scalar.

[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator%(
    safe_int lhs,
    U rhs);
» more...

Computes the remainder of dividing lhs by rhs.

[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator%(
    safe_int lhs,
    safe_int rhs);
» more...

Computes the remainder of dividing a safe_int by a constrained value

[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator%(
    safe_int lhs,
    constrained<U, CP> rhs);
» more...

Computes the remainder of dividing a constrained value by a safe_int

[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator%(
    constrained<U, CP> lhs,
    safe_int rhs);
» more...

Return Value

  • the remainder, as a safe_int of the promoted result type; triggers ErrorPolicy::on_overflow on modulo by zero
  • the remainder of lhs / rhs; triggers ErrorPolicy::on_overflow on modulo by zero
  • the wrapped remainder of the underlying values

NOTE

The return value should not be discarded.

Template Parameters

NameDescription
Uthe integral scalar type

Parameters

NameDescription
lhsthe integral scalar operand
rhsthe safe_int divisor