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

Function SubtractWithOverflowGeneric

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

Source from the content-addressed store, hash-verified

90
91template <typename Int>
92[[nodiscard]] bool SubtractWithOverflowGeneric(Int u, Int v, Int* out) {
93#if USE_CHECKED_ARITHMETIC_BUILTINS
94 return __builtin_sub_overflow(u, v, out);
95#else
96 if constexpr (sizeof(Int) < 4) {
97 using UpscaledInt = upscaled_int32_t<Int>;
98 auto r = static_cast<UpscaledInt>(u) - static_cast<UpscaledInt>(v);
99 *out = static_cast<Int>(r);
100 return r != *out;
101 } else {
102 return SafeIntSubtractWithOverflow(u, v, out);
103 }
104#endif
105}
106
107template <typename Int>
108[[nodiscard]] bool MultiplyWithOverflowGeneric(Int u, Int v, Int* out) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected