| 224 | }; |
| 225 | |
| 226 | struct adder { |
| 227 | template <typename U> |
| 228 | using is_convertible_to_mp_int = typename std::is_convertible<U, mp_int>::type; |
| 229 | |
| 230 | template <typename U> |
| 231 | using is_integral = typename std::is_integral<U>::type; |
| 232 | |
| 233 | template <typename T, typename Buffer, typename U> |
| 234 | void if_integral(std::true_type, T* tp, Buffer& b, std::size_t i, const U& x) { |
| 235 | if (!safe_radd(tp[i], x)) { |
| 236 | using V = next_type<T>; |
| 237 | create(type_tag<V>(), b, tp); |
| 238 | destroyer()(tp, b); |
| 239 | operator()(reinterpret_cast<V*>(b.ptr), b, i, x); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | template <typename T, typename Buffer, typename U> |
| 244 | void if_integral(std::false_type, T* tp, Buffer& b, std::size_t i, const U& x) { |
| 245 | create(type_tag<wcount>(), b, tp); |
| 246 | destroyer()(tp, b); |
| 247 | operator()(reinterpret_cast<wcount*>(b.ptr), b, i, x); |
| 248 | } |
| 249 | |
| 250 | template <typename T, typename Buffer, typename U> |
| 251 | void operator()(T* tp, Buffer& b, std::size_t i, const U& x) { |
| 252 | if_integral(is_integral<U>(), tp, b, i, x); |
| 253 | } |
| 254 | |
| 255 | template <typename Buffer, typename U> |
| 256 | void operator()(void*, Buffer& b, std::size_t i, const U& x) { |
| 257 | using V = next_type<void>; |
| 258 | create(type_tag<V>(), b); |
| 259 | operator()(reinterpret_cast<V*>(b.ptr), b, i, x); |
| 260 | } |
| 261 | |
| 262 | template <typename Buffer, typename U> |
| 263 | void if_convertible_to_mp_int(std::true_type, mp_int* tp, Buffer&, std::size_t i, |
| 264 | const U& x) { |
| 265 | tp[i] += static_cast<mp_int>(x); |
| 266 | } |
| 267 | |
| 268 | template <typename Buffer, typename U> |
| 269 | void if_convertible_to_mp_int(std::false_type, mp_int* tp, Buffer& b, std::size_t i, |
| 270 | const U& x) { |
| 271 | create(type_tag<wcount>(), b, tp); |
| 272 | destroyer()(tp, b); |
| 273 | operator()(reinterpret_cast<wcount*>(b.ptr), b, i, x); |
| 274 | } |
| 275 | |
| 276 | template <typename Buffer, typename U> |
| 277 | void operator()(mp_int* tp, Buffer& b, std::size_t i, const U& x) { |
| 278 | if_convertible_to_mp_int(is_convertible_to_mp_int<U>(), tp, b, i, x); |
| 279 | } |
| 280 | |
| 281 | template <typename Buffer, typename U> |
| 282 | void operator()(wcount* tp, Buffer&, std::size_t i, const U& x) { |
| 283 | tp[i] += x; |
no outgoing calls
no test coverage detected