Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What guarantees does C++ make about the ordering of character literals?

What guarantees does C++ make about the ordering of character literals? Is there a definite ordering of characters in the basic source character set? (e.g. is 'a' < 'z' guaranteed to be true? How about 'A' < 'z'?)

like image 287
Luke Avatar asked Sep 15 '15 13:09

Luke


1 Answers

The standard only provides a guarantee for ordering of the decimal digits 0 to 9, from the draft C++11 standard section 2.3 [lex.charset]:

In both the source and execution basic character sets, the value of each character after 0 in the above list of decimal digits shall be one greater than the value of the previous.

and otherwise says (emphasis mine):

The basic execution character set and the basic execution wide-character set shall each contain all the members of the basic source character set, plus control characters representing alert, backspace, and carriage return, plus a null character (respectively, null wide character), whose representation has all zero bits. For each basic execution character set, the values of the members shall be non-negative and distinct from one another.

Note, EBCDIC has a non-consecutive character set.

like image 82
Shafik Yaghmour Avatar answered Sep 20 '22 12:09

Shafik Yaghmour