Is there an alternative to using static_cast <int> all the time?

I have an enumeration called StackID, and throughout my code I owe static_castit to intquite a bit - for example.

StackID somestack;
int id = static_cast<int>(somestack);

Is there a shorthand alternative to doing this cast again and again? I have heard of "implicit" conversions - is that what I can use here?

(Perhaps related to this issue )

+5
source share
3 answers

-, ? . enum int, , ( API.) static_cast ints. .

MSN enums enum- > int int- > enum ( static_cast.)

+10

?

, , ! , , :

int id = somestack;

enum int.

, , , enum , . ( , , , . , , .)

+2

Enum . . int. , , #define, Enum.

0

All Articles