Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
strong_int.h File Reference
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iosfwd>
#include <iterator>
#include <limits>
#include <ostream>
#include <string>
#include <type_traits>
#include <utility>
#include "absl/meta/type_traits.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"

Go to the source code of this file.

Macros

#define STRONG_INT_VS_STRONG_INT_BINARY_OP(op, validator)
#define STRONG_INT_VS_NUMERIC_BINARY_OP(op, validator)
#define NUMERIC_VS_STRONG_INT_BINARY_OP(op, validator)
#define STRONG_INT_COMPARISON_OP(op)
#define DEFINE_STRONG_INT_TYPE(type_name, value_type)

Macro Definition Documentation

◆ DEFINE_STRONG_INT_TYPE

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

◆ NUMERIC_VS_STRONG_INT_BINARY_OP

#define NUMERIC_VS_STRONG_INT_BINARY_OP ( op,
validator )
Value:
template <typename TagType, typename ValueType, typename ValidatorType, \
typename NumType, \
std::enable_if_t<!IsStrongIntV<NumType>>* = nullptr> \
constexpr StrongInt<TagType, ValueType, ValidatorType> operator op( \
NumType lhs, StrongInt<TagType, ValueType, ValidatorType> rhs) { \
return ValidatorType::template validator<ValueType>(rhs.value(), lhs), \
StrongInt<TagType, ValueType, ValidatorType>( \
static_cast<ValueType>(rhs.value() op lhs)); \
}

◆ STRONG_INT_COMPARISON_OP

#define STRONG_INT_COMPARISON_OP ( op)
Value:
template <typename TagType, typename ValueType, typename ValidatorType> \
constexpr bool operator op( \
StrongInt<TagType, ValueType, ValidatorType> lhs, \
StrongInt<TagType, ValueType, ValidatorType> rhs) { \
return lhs.value() op rhs.value(); \
}

◆ STRONG_INT_VS_NUMERIC_BINARY_OP

#define STRONG_INT_VS_NUMERIC_BINARY_OP ( op,
validator )
Value:
template <typename TagType, typename ValueType, typename ValidatorType, \
typename NumType, \
std::enable_if_t<!IsStrongIntV<NumType>>* = nullptr> \
constexpr StrongInt<TagType, ValueType, ValidatorType> operator op( \
StrongInt<TagType, ValueType, ValidatorType> lhs, NumType rhs) { \
return ValidatorType::template validator<ValueType>(lhs.value(), rhs), \
StrongInt<TagType, ValueType, ValidatorType>( \
static_cast<ValueType>(lhs.value() op rhs)); \
}

◆ STRONG_INT_VS_STRONG_INT_BINARY_OP

#define STRONG_INT_VS_STRONG_INT_BINARY_OP ( op,
validator )
Value:
template <typename TagType, typename ValueType, typename ValidatorType> \
constexpr StrongInt<TagType, ValueType, ValidatorType> operator op( \
StrongInt<TagType, ValueType, ValidatorType> lhs, \
StrongInt<TagType, ValueType, ValidatorType> rhs) { \
return ValidatorType::template validator<ValueType>(lhs.value(), \
rhs.value()), \
StrongInt<TagType, ValueType, ValidatorType>( \
static_cast<ValueType>(lhs.value() op rhs.value())); \
}