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]

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_intoperator*= (strong_int const &other)
 
strong_intoperator/= (strong_int const &other)
 
strong_int operator% (strong_int const &other) const
 
strong_int operator- () const
 
strong_int operator* (strong_int const &other) const
 
strong_int operator/ (strong_int const &other) 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

◆ strong_int() [1/2]

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 
)
inlineexplicitconstexpr

Definition at line 86 of file strong_int.hxx.

References value.

◆ strong_int() [2/2]

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

Member Function Documentation

◆ anyOf() [1/2]

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

◆ anyOf() [2/2]

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

Definition at line 127 of file strong_int.hxx.

References v.

Referenced by o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::anyOf().

◆ get()

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

◆ operator bool()

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

◆ operator UNDERLYING_TYPE()

template<typename UNDERLYING_TYPE , typename PHANTOM_TYPE >
constexpr o3tl::strong_int< UNDERLYING_TYPE, PHANTOM_TYPE >::operator UNDERLYING_TYPE ( ) const
inlineexplicitconstexpr

Definition at line 99 of file strong_int.hxx.

◆ operator!=()

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

◆ operator%()

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

◆ operator%=()

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

◆ operator*()

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

◆ operator*=()

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

◆ operator++() [1/2]

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

◆ operator++() [2/2]

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

◆ operator+=()

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

◆ operator-()

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

◆ operator--() [1/2]

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

◆ operator--() [2/2]

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

◆ operator-=()

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

◆ operator/()

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

◆ operator/=()

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

◆ operator<()

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

◆ operator<=()

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

◆ operator==()

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

◆ operator>()

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

◆ operator>=()

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

Member Data Documentation

◆ m_value

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: