LibreOffice Module o3tl (master)  1
Public Member Functions | Private Attributes | List of all members
o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > Struct Template Reference

Wrap up an integer type so that we prevent accidental conversion to other integer types. More...

#include <strong_int.hxx>

Inheritance diagram for o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >:
[legend]
Collaboration diagram for o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >:
[legend]

Public Member Functions

template<typename T >
constexpr strong_int (T value, typename std::enable_if< std::is_integral< T >::value, int >::type=0)
 
 strong_int ()
 
constexpr operator UNDERLYING_TYPE () const
 
 operator bool () const
 
UNDERLYING_TYPE get () const
 
bool operator< (strong_int const &other) const
 
bool operator<= (strong_int const &other) const
 
bool operator> (strong_int const &other) const
 
bool operator>= (strong_int const &other) const
 
bool operator== (strong_int const &other) const
 
bool operator!= (strong_int const &other) const
 
strong_intoperator++ ()
 
strong_int operator++ (int)
 
strong_intoperator-- ()
 
strong_int operator-- (int)
 
strong_intoperator+= (strong_int const &other)
 
strong_intoperator-= (strong_int const &other)
 
strong_intoperator%= (strong_int const &other)
 
strong_int operator% (strong_int const &other) const
 
strong_int operator- () const
 
bool anyOf (strong_int v) const
 
template<typename... Args>
bool anyOf (strong_int first, Args...args) const
 

Private Attributes

UNDERLYING_TYPE m_value
 

Detailed Description

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
struct o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >

Wrap up an integer type so that we prevent accidental conversion to other integer types.

e.g. typedef o3tl::strong_int<unsigned, struct MyIntTag> MyInt;

Parameters
UNDERLYING_TYPEthe underlying scalar type
PHANTOM_TYPEa type tag, used to distinguish this instantiation of the template from other instantiations with the same UNDERLYING_TYPE.

Definition at line 83 of file strong_int.hxx.

Constructor & Destructor Documentation

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
template<typename T >
constexpr o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::strong_int ( value,
typename std::enable_if< std::is_integral< T >::value, int >::type  = 0 
)
inlineexplicit

Definition at line 86 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::strong_int ( )
inline

Member Function Documentation

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::anyOf ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >  v) const
inline
template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
template<typename... Args>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::anyOf ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >  first,
Args...  args 
) const
inline

Definition at line 126 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
UNDERLYING_TYPE o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::get ( ) const
inline

Definition at line 101 of file strong_int.hxx.

Referenced by o3tl::operator+(), and o3tl::operator-().

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator bool ( ) const
inlineexplicit

Definition at line 100 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
constexpr o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator UNDERLYING_TYPE ( ) const
inlineexplicit
template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator!= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 108 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator% ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 117 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int& o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator%= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other)
inline

Definition at line 115 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int& o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator++ ( )
inline

Definition at line 109 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator++ ( int  )
inline

Definition at line 110 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int& o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator+= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other)
inline

Definition at line 113 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator- ( ) const
inline

Definition at line 119 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int& o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator-- ( )
inline

Definition at line 111 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator-- ( int  )
inline

Definition at line 112 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
strong_int& o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator-= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other)
inline

Definition at line 114 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator< ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 103 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator<= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 104 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator== ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 107 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator> ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 105 of file strong_int.hxx.

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
bool o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator>= ( strong_int< UNDERLYING_TYPE, PHANTOM_TYPE > const &  other) const
inline

Definition at line 106 of file strong_int.hxx.

Member Data Documentation

template<typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
UNDERLYING_TYPE o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::m_value
private

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