Alternative Tokens

Some symbols have multiple representations, as shown in Table 1-2. These alternative tokens have no special meaning in a character or string literal. They are merely alternative representations of common symbols. Most programmers do not use alternative tokens, especially the nonalphabetic ones. Some programmers find and, or, and not to be easier to read and understand than &&, ||, and !.

Table 1-2. Alternative tokens

Alternative token

Primary token

<%

{

%>

}

<:

[

:>

]

%:

#

%:%:

##

and

&&

and_eq

&=

bitand

&

bitor

|

compl

~

not

!

not_eq

!=

or

||

or_eq

|=

xor

^

xor_eq

^=

image with no caption

Many compilers do not support some or even all of the alternative tokens. In particular, some compilers do not treat alternative keywords (and, or, etc.) as reserved keywords, but allow you to use them as identifiers. Fortunately, this problem is becoming less common as more vendors hew closer to the standard. Compilers that do not support the alternative keywords might provide them as macros in the <ciso646> header. See Chapter 13 for more information.

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.