|
Lines 29-35
inline bool checkedAssign(long long lz, int *z) {
Link Here
|
| 29 |
#endif |
29 |
#endif |
| 30 |
|
30 |
|
| 31 |
inline bool checkedAdd(int x, int y, int *z) { |
31 |
inline bool checkedAdd(int x, int y, int *z) { |
| 32 |
#if __GNUC__ >= 5 || __has_builtin(__builtin_sadd_overflow) |
32 |
#if !(defined __LCC__ && __LCC__ <= 123) && __GNUC__ >= 5 || __has_builtin(__builtin_sadd_overflow) |
| 33 |
return __builtin_sadd_overflow(x, y, z); |
33 |
return __builtin_sadd_overflow(x, y, z); |
| 34 |
#else |
34 |
#else |
| 35 |
const auto lz = static_cast<long long>(x) + static_cast<long long>(y); |
35 |
const auto lz = static_cast<long long>(x) + static_cast<long long>(y); |
|
Lines 38-44
inline bool checkedAdd(int x, int y, int *z) {
Link Here
|
| 38 |
} |
38 |
} |
| 39 |
|
39 |
|
| 40 |
inline bool checkedMultiply(int x, int y, int *z) { |
40 |
inline bool checkedMultiply(int x, int y, int *z) { |
| 41 |
#if __GNUC__ >= 5 || __has_builtin(__builtin_smul_overflow) |
41 |
#if !(defined __LCC__ && __LCC__ <= 123) && __GNUC__ >= 5 || __has_builtin(__builtin_smul_overflow) |
| 42 |
return __builtin_smul_overflow(x, y, z); |
42 |
return __builtin_smul_overflow(x, y, z); |
| 43 |
#else |
43 |
#else |
| 44 |
const auto lz = static_cast<long long>(x) * static_cast<long long>(y); |
44 |
const auto lz = static_cast<long long>(x) * static_cast<long long>(y); |
| 45 |
- |
|
|