tmp/tmpwps91jhz/{from.md → to.md}
RENAMED
|
@@ -1,32 +1,32 @@
|
|
| 1 |
#### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
|
| 2 |
|
| 3 |
-
The unary `*` operator performs *indirection*
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
function to which the
|
| 7 |
-
is “pointer to `T`”, the type of the result is “`T`”.
|
| 8 |
|
| 9 |
[*Note 1*: Indirection through a pointer to an incomplete type (other
|
| 10 |
than cv `void`) is valid. The lvalue thus obtained can be used in
|
| 11 |
limited ways (to initialize a reference, for example); this lvalue must
|
| 12 |
not be converted to a prvalue, see [[conv.lval]]. — *end note*]
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
The
|
|
|
|
| 17 |
|
| 18 |
- If the operand is a *qualified-id* naming a non-static or variant
|
| 19 |
-
member `m` of some class `C`
|
| 20 |
-
“pointer to member of class `C` of type
|
| 21 |
-
|
| 22 |
-
- Otherwise,
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
\[*Note 2*: In particular, taking
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
[*Example 1*:
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
struct A { int i; };
|
|
@@ -59,43 +59,52 @@ the *unqualified-id*’s class. — *end note*]
|
|
| 59 |
If `&` is applied to an lvalue of incomplete class type and the complete
|
| 60 |
type declares `operator&()`, it is unspecified whether the operator has
|
| 61 |
the built-in meaning or the operator function is called. The operand of
|
| 62 |
`&` shall not be a bit-field.
|
| 63 |
|
| 64 |
-
[*Note 5*: The address of an
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
function”. — *end note*]
|
| 71 |
|
| 72 |
The operand of the unary `+` operator shall have arithmetic, unscoped
|
| 73 |
enumeration, or pointer type and the result is the value of the
|
| 74 |
argument. Integral promotion is performed on integral or enumeration
|
| 75 |
operands. The type of the result is the type of the promoted operand.
|
| 76 |
|
| 77 |
The operand of the unary `-` operator shall have arithmetic or unscoped
|
| 78 |
-
enumeration type and the result is the
|
| 79 |
promotion is performed on integral or enumeration operands. The negative
|
| 80 |
of an unsigned quantity is computed by subtracting its value from 2ⁿ,
|
| 81 |
where n is the number of bits in the promoted operand. The type of the
|
| 82 |
result is the type of the promoted operand.
|
| 83 |
|
|
|
|
|
|
|
|
|
|
| 84 |
The operand of the logical negation operator `!` is contextually
|
| 85 |
converted to `bool` [[conv]]; its value is `true` if the converted
|
| 86 |
operand is `false` and `false` otherwise. The type of the result is
|
| 87 |
`bool`.
|
| 88 |
|
| 89 |
-
The operand of `~` shall have integral or unscoped
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
There is an ambiguity in the grammar when `~` is followed by a
|
| 93 |
*type-name* or *decltype-specifier*. The ambiguity is resolved by
|
| 94 |
-
treating `~` as the
|
| 95 |
-
|
| 96 |
|
| 97 |
-
[*Note
|
| 98 |
the `.`, `->`, or `::` tokens, a `~` followed by a *type-name* or
|
| 99 |
*decltype-specifier* in a member access expression or *qualified-id* is
|
| 100 |
unambiguously parsed as a destructor name. — *end note*]
|
| 101 |
|
|
|
|
| 1 |
#### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
|
| 2 |
|
| 3 |
+
The unary `*` operator performs *indirection*. Its operand shall be a
|
| 4 |
+
prvalue of type “pointer to `T`”, where `T` is an object or function
|
| 5 |
+
type. The operator yields an lvalue of type `T` denoting the object or
|
| 6 |
+
function to which the operand points.
|
|
|
|
| 7 |
|
| 8 |
[*Note 1*: Indirection through a pointer to an incomplete type (other
|
| 9 |
than cv `void`) is valid. The lvalue thus obtained can be used in
|
| 10 |
limited ways (to initialize a reference, for example); this lvalue must
|
| 11 |
not be converted to a prvalue, see [[conv.lval]]. — *end note*]
|
| 12 |
|
| 13 |
+
Each of the following unary operators yields a prvalue.
|
| 14 |
|
| 15 |
+
The operand of the unary `&` operator shall be an lvalue of some type
|
| 16 |
+
`T`. The result is a prvalue.
|
| 17 |
|
| 18 |
- If the operand is a *qualified-id* naming a non-static or variant
|
| 19 |
+
member `m` of some class `C`, other than an explicit object member
|
| 20 |
+
function, the result has type “pointer to member of class `C` of type
|
| 21 |
+
`T`” and designates `C::m`.
|
| 22 |
+
- Otherwise, the result has type “pointer to `T`” and points to the
|
| 23 |
+
designated object [[intro.memory]] or function [[basic.compound]]. If
|
| 24 |
+
the operand names an explicit object member function [[dcl.fct]], the
|
| 25 |
+
operand shall be a *qualified-id*. \[*Note 2*: In particular, taking
|
| 26 |
+
the address of a variable of type “cv `T`” yields a pointer of type
|
| 27 |
+
“pointer to cv `T`”. — *end note*]
|
| 28 |
|
| 29 |
[*Example 1*:
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
struct A { int i; };
|
|
|
|
| 59 |
If `&` is applied to an lvalue of incomplete class type and the complete
|
| 60 |
type declares `operator&()`, it is unspecified whether the operator has
|
| 61 |
the built-in meaning or the operator function is called. The operand of
|
| 62 |
`&` shall not be a bit-field.
|
| 63 |
|
| 64 |
+
[*Note 5*: The address of an overload set [[over]] can be taken only in
|
| 65 |
+
a context that uniquely determines which function is referred to (see
|
| 66 |
+
[[over.over]]). Since the context can affect whether the operand is a
|
| 67 |
+
static or non-static member function, the context can also affect
|
| 68 |
+
whether the expression has type “pointer to function” or “pointer to
|
| 69 |
+
member function”. — *end note*]
|
|
|
|
| 70 |
|
| 71 |
The operand of the unary `+` operator shall have arithmetic, unscoped
|
| 72 |
enumeration, or pointer type and the result is the value of the
|
| 73 |
argument. Integral promotion is performed on integral or enumeration
|
| 74 |
operands. The type of the result is the type of the promoted operand.
|
| 75 |
|
| 76 |
The operand of the unary `-` operator shall have arithmetic or unscoped
|
| 77 |
+
enumeration type and the result is the negative of its operand. Integral
|
| 78 |
promotion is performed on integral or enumeration operands. The negative
|
| 79 |
of an unsigned quantity is computed by subtracting its value from 2ⁿ,
|
| 80 |
where n is the number of bits in the promoted operand. The type of the
|
| 81 |
result is the type of the promoted operand.
|
| 82 |
|
| 83 |
+
[*Note 6*: The result is the two’s complement of the operand (where
|
| 84 |
+
operand and result are considered as unsigned). — *end note*]
|
| 85 |
+
|
| 86 |
The operand of the logical negation operator `!` is contextually
|
| 87 |
converted to `bool` [[conv]]; its value is `true` if the converted
|
| 88 |
operand is `false` and `false` otherwise. The type of the result is
|
| 89 |
`bool`.
|
| 90 |
|
| 91 |
+
The operand of the `~` operator shall have integral or unscoped
|
| 92 |
+
enumeration type. Integral promotions are performed. The type of the
|
| 93 |
+
result is the type of the promoted operand. Given the coefficients `xᵢ`
|
| 94 |
+
of the base-2 representation [[basic.fundamental]] of the promoted
|
| 95 |
+
operand `x`, the coefficient `rᵢ` of the base-2 representation of the
|
| 96 |
+
result `r` is 1 if `xᵢ` is 0, and 0 otherwise.
|
| 97 |
+
|
| 98 |
+
[*Note 7*: The result is the ones’ complement of the operand (where
|
| 99 |
+
operand and result are considered as unsigned). — *end note*]
|
| 100 |
+
|
| 101 |
There is an ambiguity in the grammar when `~` is followed by a
|
| 102 |
*type-name* or *decltype-specifier*. The ambiguity is resolved by
|
| 103 |
+
treating `~` as the operator rather than as the start of an
|
| 104 |
+
*unqualified-id* naming a destructor.
|
| 105 |
|
| 106 |
+
[*Note 8*: Because the grammar does not permit an operator to follow
|
| 107 |
the `.`, `->`, or `::` tokens, a `~` followed by a *type-name* or
|
| 108 |
*decltype-specifier* in a member access expression or *qualified-id* is
|
| 109 |
unambiguously parsed as a destructor name. — *end note*]
|
| 110 |
|