Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
util_intops::StrongInt< StrongIntName, _ValueType > Class Template Reference

#include <strong_int.h>

Classes

struct  Hasher
 

Public Types

typedef _ValueType ValueType
 
typedef StrongInt< StrongIntName, ValueTypeThisType
 

Public Member Functions

constexpr StrongInt ()
 Default c'tor initializing value_ to 0.
 
constexpr StrongInt (ValueType value)
 C'tor explicitly initializing from a ValueType.
 
constexpr ValueType value () const
 
template<typename ValType >
constexpr ValType value () const
 
template<typename T , typename = std::enable_if_t<std::conjunction_v< std::bool_constant<std::numeric_limits<T>::is_integer>, std::is_convertible<ValueType, T>>>>
constexpr operator T () const
 
ThisTypeoperator++ ()
 – UNARY OPERATORS -----------------------------------------------------—
 
const ThisType operator++ (int v)
 
ThisTypeoperator-- ()
 
const ThisType operator-- (int v)
 
constexpr bool operator! () const
 
constexpr const ThisType operator+ () const
 
constexpr const ThisType operator- () const
 
constexpr const ThisType operator~ () const
 
 STRONG_INT_TYPE_ASSIGNMENT_OP (+=)
 
 STRONG_INT_TYPE_ASSIGNMENT_OP (-=)
 
STRONG_INT_TYPE_ASSIGNMENT_OP * STRONG_INT_TYPE_ASSIGNMENT_OP (/=);STRONG_INT_TYPE_ASSIGNMENT_OP(<<=
 
 STRONG_INT_TYPE_ASSIGNMENT_OP (> >=)
 
 STRONG_INT_TYPE_ASSIGNMENT_OP (%=)
 
ThisTypeoperator= (ValueType arg_value)
 

Static Public Member Functions

static constexpr absl::string_view TypeName ()
 

Detailed Description

template<typename StrongIntName, typename _ValueType>
class util_intops::StrongInt< StrongIntName, _ValueType >

Holds a integral value (of type ValueType) and behaves as a ValueType by exposing assignment, unary, comparison, and arithmetic operators.

The template parameter StrongIntName defines the name for the int type and must be unique within a binary (the convenient DEFINE_STRONG_INT macro at the end of the file generates a unique StrongIntName). The parameter ValueType defines the integer type value (see supported list above).

This class is NOT thread-safe.

Definition at line 186 of file strong_int.h.

Member Typedef Documentation

◆ ThisType

template<typename StrongIntName , typename _ValueType >
StrongInt<StrongIntName, ValueType> util_intops::StrongInt< StrongIntName, _ValueType >::ThisType

Definition at line 189 of file strong_int.h.

◆ ValueType

template<typename StrongIntName , typename _ValueType >
_ValueType util_intops::StrongInt< StrongIntName, _ValueType >::ValueType

Definition at line 188 of file strong_int.h.

Constructor & Destructor Documentation

◆ StrongInt() [1/2]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::StrongInt ( )
inlineconstexpr

Default c'tor initializing value_ to 0.

Definition at line 205 of file strong_int.h.

◆ StrongInt() [2/2]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::StrongInt ( ValueType value)
inlineexplicitconstexpr

C'tor explicitly initializing from a ValueType.

Definition at line 207 of file strong_int.h.

Member Function Documentation

◆ operator T()

template<typename StrongIntName , typename _ValueType >
template<typename T , typename = std::enable_if_t<std::conjunction_v< std::bool_constant<std::numeric_limits<T>::is_integer>, std::is_convertible<ValueType, T>>>>
util_intops::StrongInt< StrongIntName, _ValueType >::operator T ( ) const
inlineexplicitconstexpr

Explicitly cast the raw value only if the underlying value is convertible to T.

Definition at line 230 of file strong_int.h.

◆ operator!()

template<typename StrongIntName , typename _ValueType >
bool util_intops::StrongInt< StrongIntName, _ValueType >::operator! ( ) const
inlineconstexpr

Definition at line 254 of file strong_int.h.

◆ operator+()

template<typename StrongIntName , typename _ValueType >
const ThisType util_intops::StrongInt< StrongIntName, _ValueType >::operator+ ( ) const
inlineconstexpr

Definition at line 255 of file strong_int.h.

◆ operator++() [1/2]

template<typename StrongIntName , typename _ValueType >
ThisType & util_intops::StrongInt< StrongIntName, _ValueType >::operator++ ( )
inline

– UNARY OPERATORS -----------------------------------------------------—

Definition at line 235 of file strong_int.h.

◆ operator++() [2/2]

template<typename StrongIntName , typename _ValueType >
const ThisType util_intops::StrongInt< StrongIntName, _ValueType >::operator++ ( int v)
inline

Definition at line 239 of file strong_int.h.

◆ operator-()

template<typename StrongIntName , typename _ValueType >
const ThisType util_intops::StrongInt< StrongIntName, _ValueType >::operator- ( ) const
inlineconstexpr

Definition at line 256 of file strong_int.h.

◆ operator--() [1/2]

template<typename StrongIntName , typename _ValueType >
ThisType & util_intops::StrongInt< StrongIntName, _ValueType >::operator-- ( )
inline

Definition at line 244 of file strong_int.h.

◆ operator--() [2/2]

template<typename StrongIntName , typename _ValueType >
const ThisType util_intops::StrongInt< StrongIntName, _ValueType >::operator-- ( int v)
inline

Definition at line 248 of file strong_int.h.

◆ operator=()

template<typename StrongIntName , typename _ValueType >
ThisType & util_intops::StrongInt< StrongIntName, _ValueType >::operator= ( ValueType arg_value)
inline

Definition at line 280 of file strong_int.h.

◆ operator~()

template<typename StrongIntName , typename _ValueType >
const ThisType util_intops::StrongInt< StrongIntName, _ValueType >::operator~ ( ) const
inlineconstexpr

Definition at line 257 of file strong_int.h.

◆ STRONG_INT_TYPE_ASSIGNMENT_OP() [1/5]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::STRONG_INT_TYPE_ASSIGNMENT_OP ( % )

◆ STRONG_INT_TYPE_ASSIGNMENT_OP() [2/5]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::STRONG_INT_TYPE_ASSIGNMENT_OP ( + )

◆ STRONG_INT_TYPE_ASSIGNMENT_OP() [3/5]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::STRONG_INT_TYPE_ASSIGNMENT_OP ( - )

◆ STRONG_INT_TYPE_ASSIGNMENT_OP() [4/5]

template<typename StrongIntName , typename _ValueType >
STRONG_INT_TYPE_ASSIGNMENT_OP * util_intops::StrongInt< StrongIntName, _ValueType >::STRONG_INT_TYPE_ASSIGNMENT_OP ( / )

◆ STRONG_INT_TYPE_ASSIGNMENT_OP() [5/5]

template<typename StrongIntName , typename _ValueType >
util_intops::StrongInt< StrongIntName, _ValueType >::STRONG_INT_TYPE_ASSIGNMENT_OP ( >= )

◆ TypeName()

template<typename StrongIntName , typename _ValueType >
static constexpr absl::string_view util_intops::StrongInt< StrongIntName, _ValueType >::TypeName ( )
inlinestaticconstexpr

Definition at line 191 of file strong_int.h.

◆ value() [1/2]

template<typename StrongIntName , typename _ValueType >
ValueType util_intops::StrongInt< StrongIntName, _ValueType >::value ( ) const
inlineconstexpr

StrongInt uses the default copy constructor, destructor and assign operator. The defaults are sufficient and omitting them allows the compiler to add the move constructor/assignment. – ACCESSORS -----------------------------------------------------------— The class provides a value() accessor returning the stored ValueType value_ as well as a templatized accessor that is just a syntactic sugar for static_cast<T>(var.value());

Definition at line 217 of file strong_int.h.

◆ value() [2/2]

template<typename StrongIntName , typename _ValueType >
template<typename ValType >
ValType util_intops::StrongInt< StrongIntName, _ValueType >::value ( ) const
inlineconstexpr

Definition at line 220 of file strong_int.h.


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