From Jason Turner

[expr.unary.op]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxhejdrp3/{from.md → to.md} +29 -34
tmp/tmpxhejdrp3/{from.md → to.md} RENAMED
@@ -1,36 +1,32 @@
1
- ### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
2
 
3
  The unary `*` operator performs *indirection*: the expression to which
4
  it is applied shall be a pointer to an object type, or a pointer to a
5
  function type and the result is an lvalue referring to the object or
6
  function to which the expression points. If the type of the expression
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
  The result of each of the following unary operators is a prvalue.
15
 
16
- The result of the unary `&` operator is a pointer to its operand. The
17
- operand shall be an lvalue or a *qualified-id*. If the operand is a
18
- *qualified-id* naming a non-static or variant member `m` of some class
19
- `C` with type `T`, the result has type “pointer to member of class `C`
20
- of type `T`” and is a prvalue designating `C::m`. Otherwise, if the type
21
- of the expression is `T`, the result has type “pointer to `T`” and is a
22
- prvalue that is the address of the designated object ([[intro.memory]])
23
- or a pointer to the designated function.
24
 
25
- [*Note 2*: In particular, the address of an object of type “cv `T`” is
26
- “pointer to cv `T`”, with the same cv-qualification. *end note*]
27
-
28
- For purposes of pointer arithmetic ([[expr.add]]) and comparison (
29
- [[expr.rel]], [[expr.eq]]), an object that is not an array element whose
30
- address is taken in this way is considered to belong to an array with
31
- one element of type `T`.
 
 
 
32
 
33
  [*Example 1*:
34
 
35
  ``` cpp
36
  struct A { int i; };
@@ -43,38 +39,37 @@ bool b = p2 > p1; // defined behavior, with value true
43
  ```
44
 
45
  — *end example*]
46
 
47
  [*Note 3*: A pointer to member formed from a `mutable` non-static data
48
- member ([[dcl.stc]]) does not reflect the `mutable` specifier
49
- associated with the non-static data member. — *end note*]
50
 
51
  A pointer to member is only formed when an explicit `&` is used and its
52
  operand is a *qualified-id* not enclosed in parentheses.
53
 
54
  [*Note 4*: That is, the expression `&(qualified-id)`, where the
55
  *qualified-id* is enclosed in parentheses, does not form an expression
56
  of type “pointer to member”. Neither does `qualified-id`, because there
57
  is no implicit conversion from a *qualified-id* for a non-static member
58
  function to the type “pointer to member function” as there is from an
59
- lvalue of function type to the type “pointer to function” (
60
- [[conv.func]]). Nor is `&unqualified-id` a pointer to member, even
61
- within the scope of the *unqualified-id*’s class. — *end note*]
62
 
63
  If `&` is applied to an lvalue of incomplete class type and the complete
64
  type declares `operator&()`, it is unspecified whether the operator has
65
  the built-in meaning or the operator function is called. The operand of
66
  `&` shall not be a bit-field.
67
 
68
- The address of an overloaded function (Clause  [[over]]) can be taken
69
  only in a context that uniquely determines which version of the
70
- overloaded function is referred to (see  [[over.over]]).
71
-
72
- [*Note 5*: Since the context might determine whether the operand is a
73
- static or non-static member function, the context can also affect
74
- whether the expression has type “pointer to function” or “pointer to
75
- member function”. — *end note*]
76
 
77
  The operand of the unary `+` operator shall have arithmetic, unscoped
78
  enumeration, or pointer type and the result is the value of the
79
  argument. Integral promotion is performed on integral or enumeration
80
  operands. The type of the result is the type of the promoted operand.
@@ -85,22 +80,22 @@ promotion is performed on integral or enumeration operands. The negative
85
  of an unsigned quantity is computed by subtracting its value from 2ⁿ,
86
  where n is the number of bits in the promoted operand. The type of the
87
  result is the type of the promoted operand.
88
 
89
  The operand of the logical negation operator `!` is contextually
90
- converted to `bool` (Clause  [[conv]]); its value is `true` if the
91
- converted operand is `false` and `false` otherwise. The type of the
92
- result is `bool`.
93
 
94
  The operand of `~` shall have integral or unscoped enumeration type; the
95
  result is the ones’ complement of its operand. Integral promotions are
96
  performed. The type of the result is the type of the promoted operand.
97
  There is an ambiguity in the grammar when `~` is followed by a
98
- *class-name* or *decltype-specifier*. The ambiguity is resolved by
99
  treating `~` as the unary complement operator rather than as the start
100
  of an *unqualified-id* naming a destructor.
101
 
102
  [*Note 6*: Because the grammar does not permit an operator to follow
103
- the `.`, `->`, or `::` tokens, a `~` followed by a *class-name* or
104
  *decltype-specifier* in a member access expression or *qualified-id* is
105
  unambiguously parsed as a destructor name. — *end note*]
106
 
 
1
+ #### Unary operators <a id="expr.unary.op">[[expr.unary.op]]</a>
2
 
3
  The unary `*` operator performs *indirection*: the expression to which
4
  it is applied shall be a pointer to an object type, or a pointer to a
5
  function type and the result is an lvalue referring to the object or
6
  function to which the expression points. If the type of the expression
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
  The result of each of the following unary operators is a prvalue.
15
 
16
+ The result of the unary `&` operator is a pointer to its operand.
 
 
 
 
 
 
 
17
 
18
+ - If the operand is a *qualified-id* naming a non-static or variant
19
+ member `m` of some class `C` with type `T`, the result has type
20
+ “pointer to member of class `C` of type `T`” and is a prvalue
21
+ designating `C::m`.
22
+ - Otherwise, if the operand is an lvalue of type `T`, the resulting
23
+ expression is a prvalue of type “pointer to `T`” whose result is a
24
+ pointer to the designated object [[intro.memory]] or function.
25
+ \[*Note 2*: In particular, taking the address of a variable of type
26
+ “cv `T`” yields a pointer of type “pointer to cv `T`”. — *end note*]
27
+ - Otherwise, the program is ill-formed.
28
 
29
  [*Example 1*:
30
 
31
  ``` cpp
32
  struct A { int i; };
 
39
  ```
40
 
41
  — *end example*]
42
 
43
  [*Note 3*: A pointer to member formed from a `mutable` non-static data
44
+ member [[dcl.stc]] does not reflect the `mutable` specifier associated
45
+ with the non-static data member. — *end note*]
46
 
47
  A pointer to member is only formed when an explicit `&` is used and its
48
  operand is a *qualified-id* not enclosed in parentheses.
49
 
50
  [*Note 4*: That is, the expression `&(qualified-id)`, where the
51
  *qualified-id* is enclosed in parentheses, does not form an expression
52
  of type “pointer to member”. Neither does `qualified-id`, because there
53
  is no implicit conversion from a *qualified-id* for a non-static member
54
  function to the type “pointer to member function” as there is from an
55
+ lvalue of function type to the type “pointer to function” [[conv.func]].
56
+ Nor is `&unqualified-id` a pointer to member, even within the scope of
57
+ the *unqualified-id*’s class. — *end note*]
58
 
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 overloaded function [[over]] can be taken
65
  only in a context that uniquely determines which version of the
66
+ overloaded function is referred to (see  [[over.over]]). Since the
67
+ context might determine whether the operand is a static or non-static
68
+ member function, the context can also affect whether the expression has
69
+ type “pointer to function or “pointer to member
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.
 
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 enumeration type; the
90
  result is the ones’ complement of its operand. Integral promotions are
91
  performed. The type of the result is the type of the promoted operand.
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 unary complement operator rather than as the start
95
  of an *unqualified-id* naming a destructor.
96
 
97
  [*Note 6*: Because the grammar does not permit an operator to follow
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