#include <st-math.h>
|
| template<typename T> |
| static T | SafelyAdd (T base, T increment) |
| | Template function to add to a value without ever risking overflowing the maximum value that type can have.
|
| template<typename T> |
| static T | SafelyAddWithCap (T base, T increment, T cap=std::numeric_limits< T >::max()) |
| | Add a value to another one and cap the result.
|
◆ SafelyAdd()
template<typename T>
| T StyyxUtil::MathUtil::SafelyAdd |
( |
T | base, |
|
|
T | increment ) |
|
inlinestatic |
Template function to add to a value without ever risking overflowing the maximum value that type can have.
- Template Parameters
-
- Parameters
-
| base | The value to add to |
| increment | The value added to base |
- Returns
- The result of the addition
- Example
static T SafelyAdd(T base, T increment)
Template function to add to a value without ever risking overflowing the maximum value that type can ...
Definition st-math.h:25
- Deprecated
- Use MathUtil::SafelyAddWithCap instead. You can use it without passing a cap to cap it to numeric limits
◆ SafelyAddWithCap()
template<typename T>
| T StyyxUtil::MathUtil::SafelyAddWithCap |
( |
T | base, |
|
|
T | increment, |
|
|
T | cap = std::numeric_limits<T>::max() ) |
|
inlinestatic |
Add a value to another one and cap the result.
- Template Parameters
-
- Parameters
-
| base | The value to add to |
| increment | The value added to base |
| cap | A cap for the result. If nothing is passed, the cap will be the numeric limit |
- Returns
- the result of the addition
- Note
- If cap is less than base, the result will be capped to cap regardless of increment
The documentation for this struct was generated from the following file: