From afacffc556662ca252af013e13221d97fff07cd9 Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Tue, 1 Jun 2021 12:06:25 +0300 Subject: [PATCH] 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 --- utils/enum_option.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/enum_option.hh b/utils/enum_option.hh index 04f380a5d6..11397aa181 100644 --- a/utils/enum_option.hh +++ b/utils/enum_option.hh @@ -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& opt) {