Multiplication operators

Synopses

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

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

Multiplies 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_); };

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

Multiplies 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; };

Computes the product of lhs and rhs.

Multiplies a safe_int by a constrained value

Multiplies a safe_int by a non‐integral constrained value

Multiplies a constrained value by a safe_int

Multiplies a non‐integral constrained value by a safe_int

Return Value

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

  • the product of lhs and the wrapped value

  • the product of the wrapped value and rhs

  • the product of lhs and rhs; triggers ErrorPolicy::on_overflow on overflow

  • the wrapped product of the underlying values

Note

The return value should not be discarded.

Template Parameters

Name

Description

U

the integral scalar type

Parameters

Name

Description

lhs

the integral scalar operand

rhs

the safe_int to multiply by

Created with MrDocs