mp_units::utility::operator*

Multiplication operators

Synopses

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

Computes the product of lhs and rhs.

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

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

template<typename U>
requires (detail::integral<U> && detail::same_sign_v<U, T>)
[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator*(
    U lhs,
    safe_int rhs);
» more...

Multiplies a floating-point value by a safe_int.

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

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

template<typename U>
requires (detail::integral<U> && detail::same_sign_v<T, U>)
[[nodiscard]]
constexpr
safe_int</* implementation-defined */, ErrorPolicy>
operator*(
    safe_int lhs,
    U rhs);
» more...

Multiplies a safe_int by a floating-point value.

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

Multiplies a safe_int by a constrained value

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

Multiplies a safe_int by a non-integral constrained value

template<
    typename U,
    typename CP>
requires (!std::integral<U>)
[[nodiscard]]
constexpr
constrained<decltype(std::declval<T>() * std::declval<U>()), CP>
operator*(
    safe_int lhs,
    constrained<U, CP> const& rhs);
» more...

Multiplies a constrained value by a safe_int

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

Multiplies a non-integral constrained value by a safe_int

template<
    typename U,
    typename CP>
requires (!std::integral<U>)
[[nodiscard]]
constexpr
constrained<decltype(std::declval<U>() * std::declval<T>()), CP>
operator*(
    constrained<U, CP> const& lhs,
    safe_int rhs);
» more...

Return Value

  • the product of lhs and rhs; triggers ErrorPolicy::on_overflow on overflow
  • 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 wrapped product of the underlying values

NOTE

The return value should not be discarded.

Template Parameters

NameDescription
Uthe integral scalar type

Parameters

NameDescription
lhsthe first value to multiply
rhsthe second value to multiply