A
Angus
With the following code:
enum testenum { in, out, append };
int val = 17;
testenum myenum = static_cast<testenum>(val);
Using my compiler it looks like myenum is given a value of 17! What
strategies do you suggest for dealing with this problem. One
possibility is to do this:
enum testenum { in, out, append, testmax };
int val = 17;
if(val > testenum ::testmax)
//error
testenum myenum = static_cast<testenum>(val);
Any other ideas?
Reason I ask is enum value is taken from a message which could contain
incorrect information.
enum testenum { in, out, append };
int val = 17;
testenum myenum = static_cast<testenum>(val);
Using my compiler it looks like myenum is given a value of 17! What
strategies do you suggest for dealing with this problem. One
possibility is to do this:
enum testenum { in, out, append, testmax };
int val = 17;
if(val > testenum ::testmax)
//error
testenum myenum = static_cast<testenum>(val);
Any other ideas?
Reason I ask is enum value is taken from a message which could contain
incorrect information.