folly::checked_mul

Multiply two unsigned integers, reporting overflow instead of wrapping.

Synopsis

Declared in <folly/lang/CheckedMath.h>

template<typename T>
requires std::is_unsigned_v<T>
bool
checked_mul(
    T* result,
    T a,
    T b);

Return Value

True on success; false on overflow, in which case *result is set to zero

Parameters

NameDescription
resultOut-param receiving the product on success
aFirst factor
bSecond factor