Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
enums.h File Reference
#include <optional>
#include <ostream>
#include <type_traits>
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"

Go to the source code of this file.

Classes

struct  operations_research::math_opt::Enum< E >
struct  operations_research::math_opt::EnumProto< P >

Namespaces

namespace  operations_research
 OR-Tools root namespace.
namespace  operations_research::math_opt

Macros

#define MATH_OPT_DEFINE_ENUM(CppEnum, proto_unspecified_value)

Typedefs

using operations_research::math_opt::ProtoEnumIsValid = bool (*)(int)

Functions

template<typename E>
Enum< E >::Proto operations_research::math_opt::EnumToProto (std::optional< E > value)
template<typename E>
Enum< E >::Proto operations_research::math_opt::EnumToProto (E value)
template<typename P>
std::optional< typename EnumProto< P >::Cpp > operations_research::math_opt::EnumFromProto (P proto_value)
template<typename E>
absl::string_view operations_research::math_opt::EnumToString (E value)
template<typename E>
std::optional< absl::string_view > operations_research::math_opt::EnumToOptString (E value)
template<typename E>
std::optional< E > operations_research::math_opt::EnumFromString (absl::string_view str)
template<typename E>
std::enable_if_t< Enum< E >::kIsImplemented, std::ostream & > operations_research::math_opt::operator<< (std::ostream &out, const E value)
template<typename E, typename = std::enable_if_t<Enum<E>::kIsImplemented>>
std::ostream & operations_research::math_opt::operator<< (std::ostream &out, const std::optional< E > opt_value)

Macro Definition Documentation

◆ MATH_OPT_DEFINE_ENUM

#define MATH_OPT_DEFINE_ENUM ( CppEnum,
proto_unspecified_value )
Value:
template <> \
struct Enum<CppEnum> { \
static constexpr bool kIsImplemented = true; \
using Proto = CppEnum##Proto; \
static constexpr Proto kProtoUnspecifiedValue = proto_unspecified_value; \
static std::optional<absl::string_view> ToOptString(CppEnum value); \
static absl::Span<const CppEnum> AllValues(); \
}; \
\
template <> \
struct EnumProto<CppEnum##Proto> { \
using Cpp = CppEnum; \
static constexpr CppEnum##Proto kMin = CppEnum##Proto##_MIN; \
static constexpr CppEnum##Proto kMax = CppEnum##Proto##_MAX; \
static constexpr ProtoEnumIsValid kIsValid = CppEnum##Proto##_IsValid; \
} /* missing semicolon to force adding it at the invocation site */

Definition at line 325 of file enums.h.