Every enumeration type implicitly provides the following predefined
comparison operators:
bool operator ==(E x, E y);
bool operator !=(E x, E y);
bool operator <(E x, E y);
bool operator >(E x, E y);
bool operator <=(E x, E y);
bool operator >=(E x, E y);
The result of evaluating x op y, where x and y are expressions of an
enumeration type E with an underlying
type U, and op is one of the comparison operators, is exactly the same as
evaluating ((U)x) op ((U)y). In
other words, the enumeration type comparison operators simply compare the
underlying integral values of
the two operands.
comparison operators:
bool operator ==(E x, E y);
bool operator !=(E x, E y);
bool operator <(E x, E y);
bool operator >(E x, E y);
bool operator <=(E x, E y);
bool operator >=(E x, E y);
The result of evaluating x op y, where x and y are expressions of an
enumeration type E with an underlying
type U, and op is one of the comparison operators, is exactly the same as
evaluating ((U)x) op ((U)y). In
other words, the enumeration type comparison operators simply compare the
underlying integral values of
the two operands.
本文详细介绍了枚举类型中预定义的比较运算符,并解释了这些运算符如何通过比较底层整数值来工作。
498

被折叠的 条评论
为什么被折叠?



