Integer ceiling division (for unsigned values).
Declared in <util/overflow.h>
template<
std::unsigned_integral Dividend,
std::unsigned_integral Divisor>
[[nodiscard]]
constexpr
auto
CeilDiv(
Dividend const dividend,
Divisor const divisor);
Computes the smallest integer q such that q * divisor >= dividend. Both dividend and divisor must be unsigned, and divisor must be non-zero.
The implementation avoids overflow that can occur with (dividend + divisor - 1) / divisor.
The smallest integer q such that q * divisor >= dividend.
The return value should not be discarded.
| Name | Description |
|---|---|
| dividend | The value being divided. |
| divisor | The value to divide by, which must be non-zero. |