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

Name

Description

result

Out‐param receiving the product on success

a

First factor

b

Second factor

Created with MrDocs