20 #ifndef INCLUDED_O3TL_STRONG_INT_HXX
21 #define INCLUDED_O3TL_STRONG_INT_HXX
26 #include <type_traits>
31 #if !defined __COVERITY__
35 template<
typename T1,
typename T2> constexpr
36 typename 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();
43 template<
typename T1,
typename T2> constexpr
44 typename 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());
52 template<
typename T1,
typename T2> constexpr
53 typename 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());
61 template<
typename T1,
typename T2> constexpr
62 typename std::enable_if<
63 std::is_unsigned<T1>::value && std::is_unsigned<T2>::value,
bool>::type
65 return value <= std::numeric_limits<T1>::max();
82 template <
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; }
101 UNDERLYING_TYPE
get()
const {
return m_value; }
131 template<
typename... Args>
140 template <
typename UT,
typename PT>
146 template <
typename UT,
typename PT>
strong_int & operator+=(strong_int const &other)
strong_int operator--(int)
strong_int< UT, PT > operator+(strong_int< UT, PT > const &lhs, strong_int< UT, PT > const &rhs)
constexpr strong_int(T value, typename std::enable_if< std::is_integral< T >::value, int >::type=0)
strong_int & operator++()
strong_int< UT, PT > operator-(strong_int< UT, PT > const &lhs, strong_int< UT, PT > const &rhs)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
Wrap up an integer type so that we prevent accidental conversion to other integer types...
bool operator!=(strong_int const &other) const
bool operator<=(strong_int const &other) const
bool operator>=(strong_int const &other) const
strong_int operator%(strong_int const &other) const
UNDERLYING_TYPE get() const
strong_int & operator--()
strong_int & operator%=(strong_int const &other)
constexpr std::enable_if< std::is_signed< T1 >::value &&std::is_signed< T2 >::value, bool >::type isInRange(T2 value)
strong_int & operator-=(strong_int const &other)
strong_int operator++(int)
strong_int operator*(strong_int const &other) const
bool operator==(strong_int const &other) const
strong_int operator/(strong_int const &other) const
strong_int operator-() const
bool operator<(strong_int const &other) const
strong_int & operator/=(strong_int const &other)
bool anyOf(strong_int first, Args...args) const
bool operator>(strong_int const &other) const
bool anyOf(strong_int v) const
strong_int & operator*=(strong_int const &other)