mp_units::utility::operator/

Division operators

Synopses

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

Divides an integral scalar by a safe_int, checking for overflow.

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

Divides a floating-point value by a safe_int.

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

Divides a safe_int by an integral scalar, checking for overflow.

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

Divides a safe_int by a floating-point value.

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

Computes the quotient of dividing lhs by rhs.

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

Divides a safe_int by a constrained value

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

Divides a safe_int by a non-integral constrained value

[[nodiscard]]
constexpr
constrained<decltype(std::declval<T>() / std::declval<U>()), CP>
operator/(
    safe_int lhs,
    constrained<U, CP> const& rhs);
» more...

Divides a constrained value by a safe_int

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

Divides a non-integral constrained value by a safe_int

[[nodiscard]]
constexpr
constrained<decltype(std::declval<U>() / std::declval<T>()), CP>
operator/(
    constrained<U, CP> const& lhs,
    safe_int rhs);
» more...

Return Value

  • the quotient, as a safe_int of the promoted result type; triggers ErrorPolicy::on_overflow on overflow
  • the quotient of lhs and the wrapped value
  • the quotient of the wrapped value and rhs
  • the result of lhs / rhs; triggers ErrorPolicy::on_overflow on overflow or division by zero
  • the wrapped quotient 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 to divide by