Overflow-checked integer arithmetic for GPU byte-size and extent math.
More...
#include <cstdint>
#include <optional>
|
| std::optional< uint64_t > | donner::gpu::CheckedAdd (uint64_t a, uint64_t b) |
| | Overflow-checked addition of unsigned 64-bit sizes.
|
| std::optional< uint64_t > | donner::gpu::CheckedMul (uint64_t a, uint64_t b) |
| | Overflow-checked multiplication of unsigned 64-bit sizes.
|
Overflow-checked integer arithmetic for GPU byte-size and extent math.
◆ CheckedAdd()
| std::optional< uint64_t > donner::gpu::CheckedAdd |
( |
uint64_t | a, |
|
|
uint64_t | b ) |
|
inline |
Overflow-checked addition of unsigned 64-bit sizes.
Returns std::nullopt instead of wrapping when the sum does not fit in 64 bits. Untrusted SVG content controls geometry volume and image sizes, so GPU byte-size and extent math uses these helpers to refuse an overflowing size rather than continue with a wrapped, smaller one.
- Parameters
-
| a | First operand. |
| b | Second operand. |
- Returns
- The sum, or
std::nullopt on overflow.
◆ CheckedMul()
| std::optional< uint64_t > donner::gpu::CheckedMul |
( |
uint64_t | a, |
|
|
uint64_t | b ) |
|
inline |
Overflow-checked multiplication of unsigned 64-bit sizes.
- Parameters
-
| a | First operand. |
| b | Second operand. |
- Returns
- The product, or
std::nullopt on overflow.