#define CheckedArithmetic_h
#include "wtf/Assertions.h"
-#include "wtf/EnumClass.h"
#include "wtf/TypeTraits.h"
#include <limits>
namespace WTF {
-ENUM_CLASS(CheckedState)
+enum class CheckedState
{
DidOverflow,
DidNotOverflow
-} ENUM_CLASS_END(CheckedState);
+};
class CrashOnOverflow {
protected:
return false;
}
} // if the signs do not match this operation can't overflow
- result = lhs + rhs;
+ result = static_cast<ResultType>(lhs + rhs);
return true;
}
return false;
}
} // if the signs match this operation can't overflow
- result = lhs - rhs;
+ result = static_cast<ResultType>(lhs - rhs);
return true;
}
return false;
}
}
- result = lhs * rhs;
+ result = static_cast<ResultType>(lhs * rhs);
return true;
}