|
|
@ -4,8 +4,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <climits>
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/safe_numerics/safe_integer.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/file_sys/content_archive.h"
|
|
|
|
#include "core/file_sys/content_archive.h"
|
|
|
@ -77,13 +75,7 @@ struct CalendarTimeInternal {
|
|
|
|
|
|
|
|
|
|
|
|
template <typename TResult, typename TOperand>
|
|
|
|
template <typename TResult, typename TOperand>
|
|
|
|
static bool SafeAdd(TResult& result, TOperand op) {
|
|
|
|
static bool SafeAdd(TResult& result, TOperand op) {
|
|
|
|
const boost::safe_numerics::safe<TResult> safe_result{result};
|
|
|
|
result = result + op;
|
|
|
|
const boost::safe_numerics::safe<TOperand> safe_op{op};
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
result = safe_result + safe_op;
|
|
|
|
|
|
|
|
} catch (const std::exception&) {
|
|
|
|
|
|
|
|
return {}; // Failed with undefined behavior
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|