MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / overflowCheck

Function overflowCheck

simcore/framework/src/cli/cli.hpp:2675–2681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2673/// Do a check for overflow on signed numbers
2674template <typename T>
2675inline typename std::enable_if<std::is_signed<T>::value, T>::type overflowCheck(const T &a, const T &b) {
2676 if ((a > 0) == (b > 0)) {
2677 return ((std::numeric_limits<T>::max)() / (std::abs)(a) < (std::abs)(b));
2678 } else {
2679 return ((std::numeric_limits<T>::min)() / (std::abs)(a) > -(std::abs)(b));
2680 }
2681}
2682/// Do a check for overflow on unsigned numbers
2683template <typename T>
2684inline typename std::enable_if<!std::is_signed<T>::value, T>::type overflowCheck(const T &a, const T &b) {

Callers 1

checked_multiplyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected