Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
clamped_arithmetic.h File Reference
#include <QtGlobal>
#include <cstdint>
Include dependency graph for clamped_arithmetic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int addClamped (int value, int delta, int minValue, int maxValue)
 Overflow-safe clamped addition: returns value + delta bounded to [minValue, maxValue].

Function Documentation

◆ addClamped()

int addClamped ( int value,
int delta,
int minValue,
int maxValue )
inline

Overflow-safe clamped addition: returns value + delta bounded to [minValue, maxValue].

Uses a 64-bit intermediate so the addition cannot overflow int. Shared by the bounded counter arithmetic in both the client and the server.

Note
Requires minValue <= maxValue. Bounds come from trusted compile-time call sites; qBound() asserts this internally in debug builds.
Here is the caller graph for this function: