I wanted to ask if it is possible to use Enums with Structural bindings? I am working through a practice exercise which builds on a previous example I came up with.
I am practising how to return multiple values from a function using a tuple.
> I built a class
> The class has an accessor/getter which returns a 4 tuple
> 3 of the elements of the tuple are strings which I can tie using structural binding
> the 4th element I've been trying to grapple with is of Enum type, with an underlying type char for the football players position.
I detect some confusion about enum, maybe. Think of enums as 'a group of constants'.
you can't get the text back out without code, eg you can't print on screen that 1 is 'b', its not like that. its just that you have a const b=1 built by that enum. The underlying type of enum is whatever integer the compiler picked for it, it 'may be char', but if it is a char, its not any kind of usable text, its just a 1-byte integer.
if you want the text you have to have code akin to:
if (variable == b ) cout << 'b';
or use parallel arrays inside your own 'better enum' class.