OR-Tools  9.3
strong_int.h File Reference

Go to the source code of this file.

Classes

class  StrongInt< StrongIntName, _ValueType >
 
struct  StrongInt< StrongIntName, _ValueType >::Hasher
 
struct  hash< util_intops::StrongInt< StrongIntName, ValueType > >
 

Namespaces

namespace  util_intops
 
namespace  std
 STL namespace.
 

Macros

#define DEFINE_STRONG_INT_TYPE(int_type_name, value_type)
 
#define STRONG_INT_TYPE_ASSIGNMENT_OP(op)
 
#define STRONG_INT_TYPE_ARITHMETIC_OP(op)
 
#define STRONG_INT_TYPE_COMPARISON_OP(op)
 

Functions

template<typename StrongIntName , typename ValueType >
std::ostream & operator<< (std::ostream &os, StrongInt< StrongIntName, ValueType > arg)
 
 STRONG_INT_TYPE_ARITHMETIC_OP (+)
 
 STRONG_INT_TYPE_ARITHMETIC_OP (-)
 
STRONG_INT_TYPE_ARITHMETIC_OP * STRONG_INT_TYPE_ARITHMETIC_OP (/);STRONG_INT_TYPE_ARITHMETIC_OP(<<
 
 STRONG_INT_TYPE_ARITHMETIC_OP (> >)
 
 STRONG_INT_TYPE_ARITHMETIC_OP (%)
 
 STRONG_INT_TYPE_COMPARISON_OP (==)
 
 STRONG_INT_TYPE_COMPARISON_OP (!=)
 
 STRONG_INT_TYPE_COMPARISON_OP (<=)
 
 STRONG_INT_TYPE_COMPARISON_OP (>=)
 

Variables

class util_intops::StrongInt ABSL_ATTRIBUTE_PACKED
 

Macro Definition Documentation

◆ DEFINE_STRONG_INT_TYPE

#define DEFINE_STRONG_INT_TYPE (   int_type_name,
  value_type 
)
Value:
struct int_type_name##_tag_ { \
static constexpr absl::string_view TypeName() { return #int_type_name; } \
}; \
typedef ::util_intops::StrongInt<int_type_name##_tag_, value_type> \
int_type_name;

Definition at line 166 of file strong_int.h.

◆ STRONG_INT_TYPE_ARITHMETIC_OP

#define STRONG_INT_TYPE_ARITHMETIC_OP (   op)
Value:
template <typename StrongIntName, typename ValueType> \
constexpr StrongInt<StrongIntName, ValueType> operator op( \
StrongInt<StrongIntName, ValueType> id_1, \
StrongInt<StrongIntName, ValueType> id_2) { \
return StrongInt<StrongIntName, ValueType>(id_1.value() op id_2.value()); \
} \
template <typename StrongIntName, typename ValueType> \
constexpr StrongInt<StrongIntName, ValueType> operator op( \
StrongInt<StrongIntName, ValueType> id, \
typename StrongInt<StrongIntName, ValueType>::ValueType arg_val) { \
return StrongInt<StrongIntName, ValueType>(id.value() op arg_val); \
} \
template <typename StrongIntName, typename ValueType> \
constexpr StrongInt<StrongIntName, ValueType> operator op( \
typename StrongInt<StrongIntName, ValueType>::ValueType arg_val, \
StrongInt<StrongIntName, ValueType> id) { \
return StrongInt<StrongIntName, ValueType>(arg_val op id.value()); \
}
int64_t value

Definition at line 297 of file strong_int.h.

◆ STRONG_INT_TYPE_ASSIGNMENT_OP

#define STRONG_INT_TYPE_ASSIGNMENT_OP (   op)
Value:
ThisType& operator op(const ThisType& arg_value) { \
value_ op arg_value.value(); \
return *this; \
} \
ThisType& operator op(ValueType arg_value) { \
value_ op arg_value; \
return *this; \
}

Definition at line 249 of file strong_int.h.

◆ STRONG_INT_TYPE_COMPARISON_OP

#define STRONG_INT_TYPE_COMPARISON_OP (   op)
Value:
template <typename StrongIntName, typename ValueType> \
static inline constexpr bool operator op( \
StrongInt<StrongIntName, ValueType> id_1, \
StrongInt<StrongIntName, ValueType> id_2) { \
return id_1.value() op id_2.value(); \
} \
template <typename StrongIntName, typename ValueType> \
static inline constexpr bool operator op( \
StrongInt<StrongIntName, ValueType> id, \
typename StrongInt<StrongIntName, ValueType>::ValueType val) { \
return id.value() op val; \
} \
template <typename StrongIntName, typename ValueType> \
static inline constexpr bool operator op( \
typename StrongInt<StrongIntName, ValueType>::ValueType val, \
StrongInt<StrongIntName, ValueType> id) { \
return val op id.value(); \
}

Definition at line 331 of file strong_int.h.