Suppose I have a (compile-time) fixed set of values from a certain type, e.g. foo1
, foo2
, foo3
, foo4
of type Foo
. At runtime, I have a variable my_foo
of type Foo
, and I want to be able to check whether it is one of my foo's - not by individual independent check. So, I basically want to be able to write something like:
if ( my_foo is_in {foo1, foo2, foo3, foo4} ) do_stuff();
can I implement such an is_in
operator (could be called something else, e.g. member_of
, in
, found_in
or whatever). Is this possible?