# OverflowSafeInt< T, T_MAX, T_MIN > Class Template Reference

Overflow safe template for integers, i.e. More...

`#include <overflowsafe_type.hpp>`

## Public Member Functions
| OverflowSafeInt (const OverflowSafeInt &other)
| OverflowSafeInt (const int64 int_)
FORCEINLINE OverflowSafeInt & | operator= (const OverflowSafeInt &other)
FORCEINLINE OverflowSafeInt | operator- () const
FORCEINLINE OverflowSafeInt & | operator+= (const OverflowSafeInt &other)
| Safe implementation of addition.
FORCEINLINE OverflowSafeInt | operator+ (const OverflowSafeInt &other) const
FORCEINLINE OverflowSafeInt | operator+ (const int other) const
FORCEINLINE OverflowSafeInt | operator+ (const uint other) const
FORCEINLINE OverflowSafeInt & | operator-= (const OverflowSafeInt &other)
FORCEINLINE OverflowSafeInt | operator- (const OverflowSafeInt &other) const
FORCEINLINE OverflowSafeInt | operator- (const int other) const
FORCEINLINE OverflowSafeInt | operator- (const uint other) const
FORCEINLINE OverflowSafeInt & | operator++ ()
FORCEINLINE OverflowSafeInt & | operator-- ()
FORCEINLINE OverflowSafeInt | operator++ (int)
FORCEINLINE OverflowSafeInt | operator-- (int)
FORCEINLINE OverflowSafeInt & | operator*= (const int factor)
| Safe implementation of multiplication.
FORCEINLINE OverflowSafeInt | operator* (const int64 factor) const
FORCEINLINE OverflowSafeInt | operator* (const int factor) const
FORCEINLINE OverflowSafeInt | operator* (const uint factor) const
FORCEINLINE OverflowSafeInt | operator* (const uint16 factor) const
FORCEINLINE OverflowSafeInt | operator* (const byte factor) const
FORCEINLINE OverflowSafeInt & | operator/= (const int64 divisor)
FORCEINLINE OverflowSafeInt | operator/ (const OverflowSafeInt &divisor) const
FORCEINLINE OverflowSafeInt | operator/ (const int divisor) const
FORCEINLINE OverflowSafeInt | operator/ (const uint divisor) const
FORCEINLINE OverflowSafeInt & | operator%= (const int divisor)
FORCEINLINE OverflowSafeInt | operator% (const int divisor) const
FORCEINLINE OverflowSafeInt & | operator<<= (const int shift)
FORCEINLINE OverflowSafeInt | operator<< (const int shift) const
FORCEINLINE OverflowSafeInt & | operator>>= (const int shift)
FORCEINLINE OverflowSafeInt | operator>> (const int shift) const
FORCEINLINE bool | operator== (const OverflowSafeInt &other) const
FORCEINLINE bool | operator!= (const OverflowSafeInt &other) const
FORCEINLINE bool | operator> (const OverflowSafeInt &other) const
FORCEINLINE bool | operator>= (const OverflowSafeInt &other) const
FORCEINLINE bool | operator< (const OverflowSafeInt &other) const
FORCEINLINE bool | operator<= (const OverflowSafeInt &other) const
FORCEINLINE bool | operator== (const int other) const
FORCEINLINE bool | operator!= (const int other) const
FORCEINLINE bool | operator> (const int other) const
FORCEINLINE bool | operator>= (const int other) const
FORCEINLINE bool | operator< (const int other) const
FORCEINLINE bool | operator<= (const int other) const
FORCEINLINE | operator int64 () const
## Private Attributes
T | m_value
| The non-overflow safe backend to store the value in.

## Detailed Description

### template<class T, T T_MAX, T T_MIN>
class OverflowSafeInt< T, T_MAX, T_MIN >

Overflow safe template for integers, i.e.

integers that will never overflow you multiply the maximum value with 2, or add 2, or substract somethng from the minimum value, etc.

Parameters:

  | 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.

## Member Function Documentation

template<class T, T T_MAX, T T_MIN>

FORCEINLINE OverflowSafeInt& OverflowSafeInt< T, T_MAX, T_MIN >::operator*= | ( | const int | factor | ) | `[inline]`

Safe implementation of multiplication.

Parameters:

  | factor | the factor to multiply this with.

Note:
  when the multiplication would yield more than T_MAX (or less than T_MIN), it will be T_MAX (respectively T_MIN).

Definition at line 78 of file overflowsafe_type.hpp.

template<class T, T T_MAX, T T_MIN>

FORCEINLINE OverflowSafeInt& OverflowSafeInt< T, T_MAX, T_MIN >::operator+= | ( | const OverflowSafeInt< T, T_MAX, T_MIN > & | other | ) | `[inline]`

Safe implementation of addition.

Parameters:

  | other | the amount to add

Note:
  when the addition would yield more than T_MAX (or less than T_MIN), it will be T_MAX (respectively T_MIN).

Definition at line 47 of file overflowsafe_type.hpp.

## Field Documentation

template<class T, T T_MAX, T T_MIN>

T OverflowSafeInt< T, T_MAX, T_MIN >::m_value`[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+=().

The documentation for this class was generated from the following file:

- src/core/overflowsafe_type.hpp