Even though the C++ standard defines both "Primary" and "Alternative" operators, it is not a good idea to use the alternatives. Developers
seeing an alphabetical name expect a variable, a function, a class, a namespace… in short, anything but an operator, and they will be confused at
best by code that uses such operators.
Primary |
Alternative |
&& |
and |
&= |
and_eq |
& |
bitand |
| |
bitor |
~ |
compl |
! |
not |
!= |
not_eq |
|| |
or |
|= |
or_eq |
^ |
xor |
^= |
xor_eq |
Noncompliant code example
if (not valid or error) { // Noncompliant
/* ... */
}
Compliant solution
if (!valid || error) {
/* ... */
}