The operand of the
~ operator shall have integral or unscoped enumeration type
. Integral promotions are performed
. The type of the result is the type of the promoted operand
. Given the coefficients
xi
of the base-2 representation (
[basic.fundamental])
of the promoted operand
x,
the coefficient
ri
of the base-2 representation of the result
r
is 1 if
xi is 0, and 0 otherwise
. [
Note 7:
The result is the ones' complement of the operand
(where operand and result are considered as unsigned)
. —
end note]
The ambiguity is resolved by treating
~ as the
operator rather than as the start of an
unqualified-id
naming a destructor
. [
Note 8:
Because the grammar does not permit an operator to follow the
.,
->, or
:: tokens, a
~ followed by
a
type-name or
decltype-specifier in a
member access expression or
qualified-id is
unambiguously parsed as a destructor name
. —
end note]