cpp/language/operator alternative

C++ (and C) source code may be written in any non-ASCII 7-bit character set that includes the invariant character set. However, several C++ operators and punctuators require characters that are outside of the ISO 646 codeset:. To be able to use character encodings where some or all of these symbols do not exist (such as the German ), C++ defines the following alternatives composed of ISO 646 compatible characters.

Alternative tokens
There are alternative spellings for several operators and other tokens that use non-ISO646 characters. In all respects of the language, each alternative token behaves exactly the same as its primary token, except for its spelling (the stringification operator can make the spelling visible). The two-letter alternative tokens are sometimes called "digraphs". Despite being four-letters long, is also considered a digraph.

When the parser encounters the character sequence and the subsequent character is neither  nor, the  is treated as a preprocessing token by itself and not as the first character of the alternative token. Thus will not be wrongly treated as.

Compatibility with C
The same words are defined in the C programming language in the include file as macros. Because in C++ these are built into the language, the C++ version of, as well as , does not define anything. The non-word digraphs (e.g ), however, are part of the core language and can be used without including any header (otherwise, they would be unusable on any charset that lacks ).

Trigraphs
The following three-character groups (trigraphs) are, and each appearance of a trigraph is replaced by the corresponding primary character:

Because trigraphs are processed early, a comment such as will effectively comment out the following line, and the string literal such as  is parsed as.

Keywords
,, , , , , , , , ,