Go to the source code of this file.
|
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | ckd_add (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | ckd_mul (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | ckd_sub (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | __gnu_cxx::ckd_add (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | __gnu_cxx::ckd_mul (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
| template<typename _Tp1, typename _Tp2, typename _Tp3> |
| bool | __gnu_cxx::ckd_sub (_Tp1 *__result, _Tp2 __a, _Tp3 __b) |
This is a Standard C++ Library header.
Definition in file stdckdint.h.
◆ __STDC_VERSION_STDCKDINT_H__
| #define __STDC_VERSION_STDCKDINT_H__ |
◆ ckd_add()
template<typename _Tp1, typename _Tp2, typename _Tp3>
| bool __gnu_cxx::ckd_add |
( |
_Tp1 * | __result, |
|
|
_Tp2 | __a, |
|
|
_Tp3 | __b ) |
|
inline |
Checked integer arithmetic
Performs arithmetic on __a and __b and stores the result in *__result, with overflow detection. The arithmetic is performed in infinite signed precision, without overflow, then converted to the result type, _Tp1. If the converted result is not equal to the infinite precision result, the stored result is wrapped to the width of _Tp1 and true is returned. Otherwise, the stored result is correct and false is returned.
- Parameters
-
| __result | A pointer to a signed or unsigned integer type. |
| __a | A signed or unsigned integer type. |
| __b | A signed or unsigned integer type. |
- Returns
- True if overflow occurred, false otherwise.
- Since
- C++26
Definition at line 63 of file stdckdint.h.
◆ ckd_mul()
template<typename _Tp1, typename _Tp2, typename _Tp3>
| bool __gnu_cxx::ckd_mul |
( |
_Tp1 * | __result, |
|
|
_Tp2 | __a, |
|
|
_Tp3 | __b ) |
|
inline |
◆ ckd_sub()
template<typename _Tp1, typename _Tp2, typename _Tp3>
| bool __gnu_cxx::ckd_sub |
( |
_Tp1 * | __result, |
|
|
_Tp2 | __a, |
|
|
_Tp3 | __b ) |
|
inline |