[lex.digraph] (original) (raw)

5 Lexical conventions [lex]

5.9 Alternative tokens [lex.digraph]

Alternative token representations are provided for some operators and punctuators.10

In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling.

[Note 1:

The “stringized” values ([cpp.stringize]) of[ and <: are different, maintaining the source spelling.

— _end note_]

The set of alternative tokens is defined in Table 3.

Table 3 — Alternative tokens [tab:lex.digraph]

🔗Alternative Primary Alternative Primary Alternative Primary
🔗<% { and && and_eq &=
🔗%> } bitor | or_eq |=
🔗<: [ or | xor_eq
🔗:> ] xor ^ not !
🔗%: # compl ~ not_eq !=
🔗%:%: ## bitand &

10)10)

These include “digraphs” and additional reserved words.

The term “digraph” (token consisting of two characters) is not perfectly descriptive, since one of the alternative preprocessing-tokens is%:%: and of course several primary tokens contain two characters.

Nonetheless, those alternative tokens that aren't lexical keywords are colloquially known as “digraphs”.