MCPcopy Create free account
hub / github.com/apache/arrow / AddWithOverflowGeneric

Function AddWithOverflowGeneric

cpp/src/arrow/util/int_util_overflow.h:76–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75template <typename Int>
76[[nodiscard]] bool AddWithOverflowGeneric(Int u, Int v, Int* out) {
77#if USE_CHECKED_ARITHMETIC_BUILTINS
78 return __builtin_add_overflow(u, v, out);
79#else
80 if constexpr (sizeof(Int) < 4) {
81 using UpscaledInt = upscaled_int32_t<Int>;
82 auto r = static_cast<UpscaledInt>(u) + static_cast<UpscaledInt>(v);
83 *out = static_cast<Int>(r);
84 return r != *out;
85 } else {
86 return SafeIntAddWithOverflow(u, v, out);
87 }
88#endif
89}
90
91template <typename Int>
92[[nodiscard]] bool SubtractWithOverflowGeneric(Int u, Int v, Int* out) {

Callers 1

AddWithOverflowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected