OpenTTD Source 20241224-master-gf74b0cf984
|
Overflow safe template for integers, i.e. More...
#include <overflowsafe_type.hpp>
Public Member Functions | |
constexpr | OverflowSafeInt (const OverflowSafeInt &other) |
constexpr | OverflowSafeInt (const T int_) |
constexpr OverflowSafeInt & | operator= (const OverflowSafeInt &other) |
constexpr OverflowSafeInt & | operator= (T other) |
constexpr OverflowSafeInt | operator- () const |
constexpr OverflowSafeInt & | operator+= (const OverflowSafeInt &other) |
Safe implementation of addition. | |
constexpr OverflowSafeInt & | operator-= (const OverflowSafeInt &other) |
Safe implementation of subtraction. | |
constexpr OverflowSafeInt | operator+ (const OverflowSafeInt &other) const |
constexpr OverflowSafeInt | operator+ (const int other) const |
constexpr OverflowSafeInt | operator+ (const uint other) const |
constexpr OverflowSafeInt | operator- (const OverflowSafeInt &other) const |
constexpr OverflowSafeInt | operator- (const int other) const |
constexpr OverflowSafeInt | operator- (const uint other) const |
constexpr OverflowSafeInt & | operator++ () |
constexpr OverflowSafeInt & | operator-- () |
constexpr OverflowSafeInt | operator++ (int) |
constexpr OverflowSafeInt | operator-- (int) |
constexpr OverflowSafeInt & | operator*= (const int factor) |
Safe implementation of multiplication. | |
constexpr OverflowSafeInt | operator* (const int64_t factor) const |
constexpr OverflowSafeInt | operator* (const int factor) const |
constexpr OverflowSafeInt | operator* (const uint factor) const |
constexpr OverflowSafeInt | operator* (const uint16_t factor) const |
constexpr OverflowSafeInt | operator* (const uint8_t factor) const |
constexpr OverflowSafeInt & | operator/= (const int64_t divisor) |
constexpr OverflowSafeInt | operator/ (const OverflowSafeInt &divisor) const |
constexpr OverflowSafeInt | operator/ (const int divisor) const |
constexpr OverflowSafeInt | operator/ (const uint divisor) const |
constexpr OverflowSafeInt & | operator%= (const int divisor) |
constexpr OverflowSafeInt | operator% (const int divisor) const |
constexpr OverflowSafeInt & | operator<<= (const int shift) |
constexpr OverflowSafeInt | operator<< (const int shift) const |
constexpr OverflowSafeInt & | operator>>= (const int shift) |
constexpr OverflowSafeInt | operator>> (const int shift) const |
constexpr bool | operator== (const OverflowSafeInt &other) const |
constexpr bool | operator!= (const OverflowSafeInt &other) const |
constexpr bool | operator> (const OverflowSafeInt &other) const |
constexpr bool | operator>= (const OverflowSafeInt &other) const |
constexpr bool | operator< (const OverflowSafeInt &other) const |
constexpr bool | operator<= (const OverflowSafeInt &other) const |
constexpr bool | operator== (const int other) const |
constexpr bool | operator!= (const int other) const |
constexpr bool | operator> (const int other) const |
constexpr bool | operator>= (const int other) const |
constexpr bool | operator< (const int other) const |
constexpr bool | operator<= (const int other) const |
constexpr | operator T () const |
Static Public Member Functions | |
static constexpr OverflowSafeInt< T > | max () |
static constexpr OverflowSafeInt< T > | min () |
Private Attributes | |
T | m_value |
The non-overflow safe backend to store the value in. | |
Static Private Attributes | |
static constexpr T | T_MAX = std::numeric_limits<T>::max() |
static constexpr T | T_MIN = std::numeric_limits<T>::min() |
Overflow safe template for integers, i.e.
integers that will never overflow when 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. |
Definition at line 29 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 38 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 40 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 41 of file overflowsafe_type.hpp.
|
inlinestaticconstexpr |
Definition at line 179 of file overflowsafe_type.hpp.
|
inlinestaticconstexpr |
Definition at line 180 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 177 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 171 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 163 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 153 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 152 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 140 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 139 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 141 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 142 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 143 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Safe implementation of multiplication.
factor | the factor to multiply this with. |
Definition at line 113 of file overflowsafe_type.hpp.
References OverflowSafeInt< T >::m_value.
|
inlineconstexpr |
Definition at line 96 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 95 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 97 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 102 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 104 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Safe implementation of addition.
other | the amount to add |
Definition at line 53 of file overflowsafe_type.hpp.
References OverflowSafeInt< T >::m_value.
|
inlineconstexpr |
Definition at line 46 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 99 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 98 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 100 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 103 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 105 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Safe implementation of subtraction.
other | the amount to subtract |
Definition at line 76 of file overflowsafe_type.hpp.
References OverflowSafeInt< T >::m_value.
|
inlineconstexpr |
Definition at line 148 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 147 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 149 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 146 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 174 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 166 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 157 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 156 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 175 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 167 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 43 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 44 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 170 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 162 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 172 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 164 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 173 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 165 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 159 of file overflowsafe_type.hpp.
|
inlineconstexpr |
Definition at line 158 of file overflowsafe_type.hpp.
|
private |
The non-overflow safe backend to store the value in.
Definition at line 36 of file overflowsafe_type.hpp.
Referenced by OverflowSafeInt< T >::operator*=(), OverflowSafeInt< T >::operator+=(), and OverflowSafeInt< T >::operator-=().
|
staticconstexprprivate |
Definition at line 32 of file overflowsafe_type.hpp.
|
staticconstexprprivate |
Definition at line 33 of file overflowsafe_type.hpp.