|
OpenTTD
|
Overflow safe template for integers, i.e. More...
#include <overflowsafe_type.hpp>
Public Member Functions | |
| OverflowSafeInt (const OverflowSafeInt &other) | |
| OverflowSafeInt (const int64 int_) | |
| OverflowSafeInt & | operator= (const OverflowSafeInt &other) |
| OverflowSafeInt | operator- () const |
| OverflowSafeInt & | operator+= (const OverflowSafeInt &other) |
| Safe implementation of addition. | |
| OverflowSafeInt | operator+ (const OverflowSafeInt &other) const |
| OverflowSafeInt | operator+ (const int other) const |
| OverflowSafeInt | operator+ (const uint other) const |
| OverflowSafeInt & | operator-= (const OverflowSafeInt &other) |
| OverflowSafeInt | operator- (const OverflowSafeInt &other) const |
| OverflowSafeInt | operator- (const int other) const |
| OverflowSafeInt | operator- (const uint other) const |
| OverflowSafeInt & | operator++ () |
| OverflowSafeInt & | operator-- () |
| OverflowSafeInt | operator++ (int) |
| OverflowSafeInt | operator-- (int) |
| OverflowSafeInt & | operator*= (const int factor) |
| Safe implementation of multiplication. | |
| OverflowSafeInt | operator* (const int64 factor) const |
| OverflowSafeInt | operator* (const int factor) const |
| OverflowSafeInt | operator* (const uint factor) const |
| OverflowSafeInt | operator* (const uint16 factor) const |
| OverflowSafeInt | operator* (const byte factor) const |
| OverflowSafeInt & | operator/= (const int64 divisor) |
| OverflowSafeInt | operator/ (const OverflowSafeInt &divisor) const |
| OverflowSafeInt | operator/ (const int divisor) const |
| OverflowSafeInt | operator/ (const uint divisor) const |
| OverflowSafeInt & | operator%= (const int divisor) |
| OverflowSafeInt | operator% (const int divisor) const |
| OverflowSafeInt & | operator<<= (const int shift) |
| OverflowSafeInt | operator<< (const int shift) const |
| OverflowSafeInt & | operator>>= (const int shift) |
| OverflowSafeInt | operator>> (const int shift) const |
| bool | operator== (const OverflowSafeInt &other) const |
| bool | operator!= (const OverflowSafeInt &other) const |
| bool | operator> (const OverflowSafeInt &other) const |
| bool | operator>= (const OverflowSafeInt &other) const |
| bool | operator< (const OverflowSafeInt &other) const |
| bool | operator<= (const OverflowSafeInt &other) const |
| bool | operator== (const int other) const |
| bool | operator!= (const int other) const |
| bool | operator> (const int other) const |
| bool | operator>= (const int other) const |
| bool | operator< (const int other) const |
| bool | operator<= (const int other) const |
| operator int64 () const | |
Private Attributes | |
| T | m_value |
| The non-overflow safe backend to store the value in. | |
Overflow safe template for integers, i.e.
integers that will never overflow you multiply the maximum value with 2, or add 2, or subtract something from the minimum value, etc.
| T | the type these integers are stored with. |
| T_MAX | the maximum value for the integers. |
| T_MIN | the minimum value for the integers. |
Definition at line 26 of file overflowsafe_type.hpp.
|
inline |
Safe implementation of multiplication.
| factor | the factor to multiply this with. |
Definition at line 78 of file overflowsafe_type.hpp.
|
inline |
Safe implementation of addition.
| other | the amount to add |
Definition at line 47 of file overflowsafe_type.hpp.
|
private |
The non-overflow safe backend to store the value in.
Definition at line 30 of file overflowsafe_type.hpp.
Referenced by OverflowSafeInt< int64, INT64_MAX, INT64_MIN >::operator*=(), and OverflowSafeInt< int64, INT64_MAX, INT64_MIN >::operator+=().
1.8.1.2