| 187 | // Convenience functions over an arbitrary number of arguments |
| 188 | template <typename Int> |
| 189 | std::optional<Int> AddWithOverflow(std::initializer_list<Int> vs) { |
| 190 | if (vs.size() == 0) { |
| 191 | return {}; |
| 192 | } |
| 193 | auto it = vs.begin(); |
| 194 | Int v = *it++; |
| 195 | while (it != vs.end()) { |
| 196 | if (ARROW_PREDICT_FALSE(AddWithOverflowGeneric(v, *it++, &v))) { |
| 197 | return {}; |
| 198 | } |
| 199 | } |
| 200 | return v; |
| 201 | } |
| 202 | |
| 203 | template <typename Int> |
| 204 | std::optional<Int> MultiplyWithOverflow(std::initializer_list<Int> vs) { |