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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user