I work with a custom enumerated type in C ++, but it does not have many values. I want to try to reduce the size that they take, and I heard that enum types are always integer by default . Then I came across an MSDN entry in C ++ enumerations and found the following syntax very interesting:
enum [: type] {enum-list};
Of course, it compiled with what I wanted (VS2008) when I did the following:
enum plane : unsigned char { xy, xz, yz };
Now you can see from my enumeration constants that I don’t need much in terms of space - the unsigned char type would be ideal for my purposes.
However, I must say that I have never seen this form used anywhere else on the Internet - most are not even aware of it. I am trying to make this code cross-platform (and possibly for use on embedded systems), so I did not want to wonder ... Is this the correct C ++ syntax or is it only supported by the MSVC compiler?
As an aside, if it's legitimate C ++, why is this “function" usually not documented?
source share