utils/enum_option.hh: add implicit converter to the underlying enum

Add an implicit converter of the enum_option to the underyling enum
it is holding. This is needed for using switch() on an enum_option.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This commit is contained in:
Nadav Har'El
2021-06-01 12:06:25 +03:00
parent ec60f44b64
commit afacffc556

View File

@@ -87,9 +87,13 @@ class enum_option {
return _value == that._value;
}
// For comparison with enum values using if or switch:
bool operator==(typename map_t::mapped_type value) const {
return _value == value;
}
operator typename map_t::mapped_type() const {
return _value;
}
// For program_options parser:
friend std::istream& operator>>(std::istream& s, enum_option<Mapper>& opt) {