-
Notifications
You must be signed in to change notification settings - Fork 506
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
would it be possible to support enum_switch the way that we're used to use overload pattern with std::visit?
e.g
return magic_enum::enum_switch( overloaded{
[]( my_enum::val1 arg ) -> int { /* handle val1 enum */ return 1; },
[]( auto arg ) -> int { /* handle the rest */ throw notimplemented; /* or just return sth */ }
});
instead of
return magic_enum::enum_switch( overloaded{
[]( my_enum::val1 arg ) -> int { /* handle val1 enum */ return 1; },
[]( auto arg ) -> int { /* handle the rest */ throw notimplemented; /* or just return sth */ }
}, /*redundant default*/ int(2));
// or probably worse
auto r = magic_enum::enum_switch(
[]( my_enum::val1 arg ) -> int { /* handle val1 enum */ return 1; }
, int(2)
);
if( r == 2 ) throw notimplemented;
I think forcing adding default Result produces boilerplate.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request