![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
#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 |
| In SWIG mode, we don't want anything besides these top-level includes. | |
| namespace | operations_research::math_opt |
| An object oriented wrapper for quadratic constraints in ModelStorage. | |
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) |
| #define MATH_OPT_DEFINE_ENUM | ( | CppEnum, | |
| proto_unspecified_value ) |
Macros that defines the templates specializations for Enum and EnumProto.
The CppEnum parameter is the name of the C++ enum class which values are the Proto enum values. The C++ enum must contain a value for each value of the Proto enum but the UNSPECIFIED one. The proto_unspecified_value is the UNSPECIFIED one.
It leaves two functions to be implemented in the .cc file:
absl::string_view Enum<CppEnum>::ToOptString(CppEnum value) { absl::Span<const CppEnum> Enum<CppEnum>::AllValues();
See the comment at the top of this file for an example. See the comment on Enum struct for the functions that can then be used on enums.