20#ifndef INCLUDED_O3TL_STRONG_INT_HXX
21#define INCLUDED_O3TL_STRONG_INT_HXX
31#if !defined __COVERITY__
35template<
typename T1,
typename T2>
constexpr
36typename std::enable_if<
37 std::is_signed<T1>::value && std::is_signed<T2>::value,
bool>::type
39 return value >= std::numeric_limits<T1>::min()
40 && value <= std::numeric_limits<T1>::max();
43template<
typename T1,
typename T2>
constexpr
44typename std::enable_if<
45 std::is_signed<T1>::value && std::is_unsigned<T2>::value,
bool>::type
48 <=
static_cast<typename std::make_unsigned<T1>::type
>(
49 std::numeric_limits<T1>::max());
52template<
typename T1,
typename T2>
constexpr
53typename std::enable_if<
54 std::is_unsigned<T1>::value && std::is_signed<T2>::value,
bool>::type
57 && (
static_cast<typename std::make_unsigned<T2>::type
>(
value)
58 <= std::numeric_limits<T1>::max());
61template<
typename T1,
typename T2>
constexpr
62typename std::enable_if<
63 std::is_unsigned<T1>::value && std::is_unsigned<T2>::value,
bool>::type
65 return value <= std::numeric_limits<T1>::max();
82template <
typename UNDERLYING_TYPE,
typename PHANTOM_TYPE>
88 typename std::enable_if<std::is_integral<T>::value,
int>::type = 0):
91#if !defined __COVERITY__
93 assert(detail::isInRange<UNDERLYING_TYPE>(
value)
99 explicit constexpr operator UNDERLYING_TYPE()
const {
return m_value; }
100 explicit operator bool()
const {
return m_value != 0; }
131 template<
typename... Args>
140template <
typename UT,
typename PT>
146template <
typename UT,
typename PT>
constexpr OUStringLiteral first
constexpr std::enable_if< std::is_signed< T1 >::value &&std::is_signed< T2 >::value, bool >::type isInRange(T2 value)
strong_int< UT, PT > operator-(strong_int< UT, PT > const &lhs, strong_int< UT, PT > const &rhs)
strong_int< UT, PT > operator+(strong_int< UT, PT > const &lhs, strong_int< UT, PT > const &rhs)
Wrap up an integer type so that we prevent accidental conversion to other integer types.
bool anyOf(strong_int first, Args... args) const
bool operator==(strong_int const &other) const
strong_int operator/(strong_int const &other) const
strong_int & operator--()
strong_int operator*(strong_int const &other) const
strong_int & operator+=(strong_int const &other)
strong_int operator%(strong_int const &other) const
bool operator>=(strong_int const &other) const
strong_int & operator/=(strong_int const &other)
UNDERLYING_TYPE get() const
bool operator!=(strong_int const &other) const
bool operator<(strong_int const &other) const
constexpr strong_int(T value, typename std::enable_if< std::is_integral< T >::value, int >::type=0)
strong_int & operator%=(strong_int const &other)
strong_int operator-() const
strong_int & operator++()
strong_int & operator*=(strong_int const &other)
bool operator>(strong_int const &other) const
bool anyOf(strong_int v) const
strong_int operator--(int)
strong_int operator++(int)
strong_int & operator-=(strong_int const &other)
bool operator<=(strong_int const &other) const