Does the standard guarantee that std::less<MyEnumType> will order MyEnumType as if a value of MyEnumType was cast to an appropriately sized integer type?
enum MyEnumType { E1 = 0, E2 = 6, E3 = 3 };
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes,
std::less::operator()is defined as (§20.8.5/5):For using relational operators on enumeration types, the following is stated (§5.9/2):
For unscoped enumeration types, the usual arithmetic conversions are defined as doing integral promotion. Integral promotion for unscoped enumeration types is defined as (§5/9):
An extended integer type will be used if available and required.