12 #ifndef OVERFLOWSAFE_TYPE_HPP
13 #define OVERFLOWSAFE_TYPE_HPP
25 template <
class T, T T_MAX, T T_MIN>
80 if (factor != 0 && (T_MAX /
abs(factor)) <
abs(this->
m_value)) {
81 this->
m_value = ((this->
m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ;
113 inline bool operator != (
const OverflowSafeInt& other)
const {
return !(*
this == other); }
116 inline bool operator < (
const OverflowSafeInt& other)
const {
return !(*
this >= other); }
117 inline bool operator <= (
const OverflowSafeInt& other)
const {
return !(*
this > other); }
120 inline bool operator == (
const int other)
const {
return this->
m_value == other; }
121 inline bool operator != (
const int other)
const {
return !(*
this == other); }
122 inline bool operator > (
const int other)
const {
return this->
m_value > other; }
123 inline bool operator >= (
const int other)
const {
return this->
m_value >= other; }
124 inline bool operator < (
const int other)
const {
return !(*
this >= other); }
125 inline bool operator <= (
const int other)
const {
return !(*
this > other); }
127 inline operator int64 ()
const {
return this->
m_value; }