tmp/tmpv725dnkb/{from.md → to.md}
RENAMED
|
@@ -2,20 +2,20 @@
|
|
| 2 |
|
| 3 |
A function call is a postfix expression followed by parentheses
|
| 4 |
containing a possibly empty, comma-separated list of
|
| 5 |
*initializer-clause*s which constitute the arguments to the function.
|
| 6 |
|
| 7 |
-
[*Note 1*: If the postfix expression is a function
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
The postfix expression shall have function type or function pointer
|
| 12 |
type. For a call to a non-member function or to a static member
|
| 13 |
-
function, the postfix expression shall
|
| 14 |
to a function (in which case the function-to-pointer standard conversion
|
| 15 |
-
[[conv.func]] is suppressed on the postfix expression), or
|
| 16 |
-
pointer type.
|
| 17 |
|
| 18 |
If the selected function is non-virtual, or if the *id-expression* in
|
| 19 |
the class member access expression is a *qualified-id*, that function is
|
| 20 |
called. Otherwise, its final overrider [[class.virtual]] in the dynamic
|
| 21 |
type of the object expression is called; such a call is referred to as a
|
|
@@ -24,14 +24,13 @@ type of the object expression is called; such a call is referred to as a
|
|
| 24 |
[*Note 2*: The dynamic type is the type of the object referred to by
|
| 25 |
the current value of the object expression. [[class.cdtor]] describes
|
| 26 |
the behavior of virtual function calls when the object expression refers
|
| 27 |
to an object under construction or destruction. — *end note*]
|
| 28 |
|
| 29 |
-
[*Note 3*: If a function
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
call. — *end note*]
|
| 33 |
|
| 34 |
If the *postfix-expression* names a destructor or pseudo-destructor
|
| 35 |
[[expr.prim.id.dtor]], the type of the function call expression is
|
| 36 |
`void`; otherwise, the type of the function call expression is the
|
| 37 |
return type of the statically chosen function (i.e., ignoring the
|
|
@@ -40,41 +39,44 @@ different. If the *postfix-expression* names a pseudo-destructor (in
|
|
| 40 |
which case the *postfix-expression* is a possibly-parenthesized class
|
| 41 |
member access), the function call destroys the object of scalar type
|
| 42 |
denoted by the object expression of the class member access
|
| 43 |
[[expr.ref]], [[basic.life]].
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
-
[*Note 4*:
|
| 52 |
-
potentially-throwing function, but the called function has a
|
| 53 |
non-throwing exception specification, and the function types are
|
| 54 |
otherwise the same. — *end note*]
|
| 55 |
|
| 56 |
When a function is called, each parameter [[dcl.fct]] is initialized
|
| 57 |
-
[[dcl.init]], [[class.copy.ctor]] with its corresponding argument
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
|
| 64 |
[*Example 1*:
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
template<typename ...T> int f(int n = 0, T ...t);
|
| 68 |
int x = f<int>(); // error: no argument for second function parameter
|
| 69 |
```
|
| 70 |
|
| 71 |
— *end example*]
|
| 72 |
|
| 73 |
-
If the function is an implicit object member function, the
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
conversion [[expr.cast]].
|
| 77 |
|
| 78 |
[*Note 5*: There is no access or ambiguity checking on this conversion;
|
| 79 |
the access checking and disambiguation are done as part of the (possibly
|
| 80 |
implicit) class member access operator. See [[class.member.lookup]],
|
|
@@ -85,28 +87,37 @@ class type that is either incomplete or abstract.
|
|
| 85 |
|
| 86 |
[*Note 6*: This still allows a parameter to be a pointer or reference
|
| 87 |
to such a type. However, it prevents a passed-by-value parameter to have
|
| 88 |
an incomplete or abstract class type. — *end note*]
|
| 89 |
|
| 90 |
-
It is *implementation-defined* whether
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
[*Example 2*: The access of the constructor,
|
| 96 |
-
destructor is checked at the point of call
|
| 97 |
-
constructor or destructor for a function parameter throws an
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
handler that can handle the exception, this handler is not
|
| 101 |
considered. — *end example*]
|
| 102 |
|
| 103 |
The *postfix-expression* is sequenced before each *expression* in the
|
| 104 |
*expression-list* and any default argument. The initialization of a
|
| 105 |
-
parameter,
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
[*Note 7*: All side effects of argument evaluations are sequenced
|
| 110 |
before the function is entered (see
|
| 111 |
[[intro.execution]]). — *end note*]
|
| 112 |
|
|
@@ -150,17 +161,26 @@ control out of the called function (if any), except in a virtual
|
|
| 150 |
function call if the return type of the final overrider is different
|
| 151 |
from the return type of the statically chosen function, the value
|
| 152 |
returned from the final overrider is converted to the return type of the
|
| 153 |
statically chosen function.
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
[*Note 9*: A function can change the values of its non-const
|
| 156 |
parameters, but these changes cannot affect the values of the arguments
|
| 157 |
except where a parameter is of a reference type [[dcl.ref]]; if the
|
| 158 |
-
reference is to a const-qualified type, `const_cast`
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
[[dcl.type]], [[lex.literal]], [[lex.string]], [[dcl.array]], [[class.temporary]].
|
| 163 |
In addition, it is possible to modify the values of non-constant objects
|
| 164 |
through pointer parameters. — *end note*]
|
| 165 |
|
| 166 |
A function can be declared to accept fewer arguments (by declaring
|
|
@@ -186,15 +206,16 @@ The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
|
|
| 186 |
function-to-pointer [[conv.func]] standard conversions are performed on
|
| 187 |
the argument expression. An argument that has type cv `std::nullptr_t`
|
| 188 |
is converted to type `void*` [[conv.ptr]]. After these conversions, if
|
| 189 |
the argument does not have arithmetic, enumeration, pointer,
|
| 190 |
pointer-to-member, or class type, the program is ill-formed. Passing a
|
| 191 |
-
potentially-evaluated argument of a scoped enumeration type
|
| 192 |
-
class type [[class]] having an eligible non-trivial copy
|
| 193 |
-
|
| 194 |
-
[[
|
| 195 |
-
|
|
|
|
| 196 |
enumeration type that is subject to the integral promotions
|
| 197 |
[[conv.prom]], or a floating-point type that is subject to the
|
| 198 |
floating-point promotion [[conv.fpprom]], the value of the argument is
|
| 199 |
converted to the promoted type before the call. These promotions are
|
| 200 |
referred to as the *default argument promotions*.
|
|
@@ -202,7 +223,9 @@ referred to as the *default argument promotions*.
|
|
| 202 |
Recursive calls are permitted, except to the `main` function
|
| 203 |
[[basic.start.main]].
|
| 204 |
|
| 205 |
A function call is an lvalue if the result type is an lvalue reference
|
| 206 |
type or an rvalue reference to function type, an xvalue if the result
|
| 207 |
-
type is an rvalue reference to object type, and a prvalue otherwise.
|
|
|
|
|
|
|
| 208 |
|
|
|
|
| 2 |
|
| 3 |
A function call is a postfix expression followed by parentheses
|
| 4 |
containing a possibly empty, comma-separated list of
|
| 5 |
*initializer-clause*s which constitute the arguments to the function.
|
| 6 |
|
| 7 |
+
[*Note 1*: If the postfix expression is a function name, the
|
| 8 |
+
appropriate function and the validity of the call are determined
|
| 9 |
+
according to the rules in [[over.match]]. — *end note*]
|
| 10 |
|
| 11 |
The postfix expression shall have function type or function pointer
|
| 12 |
type. For a call to a non-member function or to a static member
|
| 13 |
+
function, the postfix expression shall be either an lvalue that refers
|
| 14 |
to a function (in which case the function-to-pointer standard conversion
|
| 15 |
+
[[conv.func]] is suppressed on the postfix expression), or a prvalue of
|
| 16 |
+
function pointer type.
|
| 17 |
|
| 18 |
If the selected function is non-virtual, or if the *id-expression* in
|
| 19 |
the class member access expression is a *qualified-id*, that function is
|
| 20 |
called. Otherwise, its final overrider [[class.virtual]] in the dynamic
|
| 21 |
type of the object expression is called; such a call is referred to as a
|
|
|
|
| 24 |
[*Note 2*: The dynamic type is the type of the object referred to by
|
| 25 |
the current value of the object expression. [[class.cdtor]] describes
|
| 26 |
the behavior of virtual function calls when the object expression refers
|
| 27 |
to an object under construction or destruction. — *end note*]
|
| 28 |
|
| 29 |
+
[*Note 3*: If a function name is used, and name lookup [[basic.lookup]]
|
| 30 |
+
does not find a declaration of that name, the program is ill-formed. No
|
| 31 |
+
function is implicitly declared by such a call. — *end note*]
|
|
|
|
| 32 |
|
| 33 |
If the *postfix-expression* names a destructor or pseudo-destructor
|
| 34 |
[[expr.prim.id.dtor]], the type of the function call expression is
|
| 35 |
`void`; otherwise, the type of the function call expression is the
|
| 36 |
return type of the statically chosen function (i.e., ignoring the
|
|
|
|
| 39 |
which case the *postfix-expression* is a possibly-parenthesized class
|
| 40 |
member access), the function call destroys the object of scalar type
|
| 41 |
denoted by the object expression of the class member access
|
| 42 |
[[expr.ref]], [[basic.life]].
|
| 43 |
|
| 44 |
+
A type `T`_call is *call-compatible* with a function type `T`_func if
|
| 45 |
+
`T`_call is the same type as `T`_func or if the type “pointer to
|
| 46 |
+
`T`_func” can be converted to type “pointer to `T`_call” via a function
|
| 47 |
+
pointer conversion [[conv.fctptr]]. Calling a function through an
|
| 48 |
+
expression whose function type is not call-compatible with the type of
|
| 49 |
+
the called function’s definition results in undefined behavior.
|
| 50 |
|
| 51 |
+
[*Note 4*: This requirement allows the case when the expression has the
|
| 52 |
+
type of a potentially-throwing function, but the called function has a
|
| 53 |
non-throwing exception specification, and the function types are
|
| 54 |
otherwise the same. — *end note*]
|
| 55 |
|
| 56 |
When a function is called, each parameter [[dcl.fct]] is initialized
|
| 57 |
+
[[dcl.init]], [[class.copy.ctor]] with its corresponding argument, and
|
| 58 |
+
each precondition assertion of the function is evaluated
|
| 59 |
+
[[dcl.contract.func]]. If the function is an explicit object member
|
| 60 |
+
function and there is an implied object argument [[over.call.func]], the
|
| 61 |
+
list of provided arguments is preceded by the implied object argument
|
| 62 |
+
for the purposes of this correspondence. If there is no corresponding
|
| 63 |
+
argument, the default argument for the parameter is used.
|
| 64 |
|
| 65 |
[*Example 1*:
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
template<typename ...T> int f(int n = 0, T ...t);
|
| 69 |
int x = f<int>(); // error: no argument for second function parameter
|
| 70 |
```
|
| 71 |
|
| 72 |
— *end example*]
|
| 73 |
|
| 74 |
+
If the function is an implicit object member function, the object
|
| 75 |
+
expression of the class member access shall be a glvalue and the
|
| 76 |
+
implicit object parameter of the function [[over.match.funcs]] is
|
| 77 |
+
initialized with that glvalue, converted as if by an explicit type
|
| 78 |
conversion [[expr.cast]].
|
| 79 |
|
| 80 |
[*Note 5*: There is no access or ambiguity checking on this conversion;
|
| 81 |
the access checking and disambiguation are done as part of the (possibly
|
| 82 |
implicit) class member access operator. See [[class.member.lookup]],
|
|
|
|
| 87 |
|
| 88 |
[*Note 6*: This still allows a parameter to be a pointer or reference
|
| 89 |
to such a type. However, it prevents a passed-by-value parameter to have
|
| 90 |
an incomplete or abstract class type. — *end note*]
|
| 91 |
|
| 92 |
+
It is *implementation-defined* whether a parameter is destroyed when the
|
| 93 |
+
function in which it is defined exits
|
| 94 |
+
[[stmt.return]], [[except.ctor]], [[expr.await]] or at the end of the
|
| 95 |
+
enclosing full-expression; parameters are always destroyed in the
|
| 96 |
+
reverse order of their construction. The initialization and destruction
|
| 97 |
+
of each parameter occurs within the context of the full-expression
|
| 98 |
+
[[intro.execution]] where the function call appears.
|
| 99 |
|
| 100 |
+
[*Example 2*: The access [[class.access.general]] of the constructor,
|
| 101 |
+
conversion functions, or destructor is checked at the point of call. If
|
| 102 |
+
a constructor or destructor for a function parameter throws an
|
| 103 |
+
exception, any *function-try-block* [[except.pre]] of the called
|
| 104 |
+
function with a handler that can handle the exception is not
|
|
|
|
| 105 |
considered. — *end example*]
|
| 106 |
|
| 107 |
The *postfix-expression* is sequenced before each *expression* in the
|
| 108 |
*expression-list* and any default argument. The initialization of a
|
| 109 |
+
parameter or, if the implementation introduces any temporary objects to
|
| 110 |
+
hold the values of function parameters [[class.temporary]], the
|
| 111 |
+
initialization of those temporaries, including every associated value
|
| 112 |
+
computation and side effect, is indeterminately sequenced with respect
|
| 113 |
+
to that of any other parameter. These evaluations are sequenced before
|
| 114 |
+
the evaluation of the precondition assertions of the function, which are
|
| 115 |
+
evaluated in sequence [[dcl.contract.func]]. For any temporaries
|
| 116 |
+
introduced to hold the values of function parameters, the initialization
|
| 117 |
+
of the parameter objects from those temporaries is indeterminately
|
| 118 |
+
sequenced with respect to the evaluation of each precondition assertion.
|
| 119 |
|
| 120 |
[*Note 7*: All side effects of argument evaluations are sequenced
|
| 121 |
before the function is entered (see
|
| 122 |
[[intro.execution]]). — *end note*]
|
| 123 |
|
|
|
|
| 161 |
function call if the return type of the final overrider is different
|
| 162 |
from the return type of the statically chosen function, the value
|
| 163 |
returned from the final overrider is converted to the return type of the
|
| 164 |
statically chosen function.
|
| 165 |
|
| 166 |
+
When the called function exits normally [[stmt.return]], [[expr.await]],
|
| 167 |
+
all postcondition assertions of the function are evaluated in sequence
|
| 168 |
+
[[dcl.contract.func]]. If the implementation introduces any temporary
|
| 169 |
+
objects to hold the result value as specified in [[class.temporary]],
|
| 170 |
+
the evaluation of each postcondition assertion is indeterminately
|
| 171 |
+
sequenced with respect to the initialization of any of those temporaries
|
| 172 |
+
or the result object. These evaluations, in turn, are sequenced before
|
| 173 |
+
the destruction of any function parameters.
|
| 174 |
+
|
| 175 |
[*Note 9*: A function can change the values of its non-const
|
| 176 |
parameters, but these changes cannot affect the values of the arguments
|
| 177 |
except where a parameter is of a reference type [[dcl.ref]]; if the
|
| 178 |
+
reference is to a const-qualified type, `const_cast` needs to be used to
|
| 179 |
+
cast away the constness in order to modify the argument’s value. Where a
|
| 180 |
+
parameter is of `const` reference type a temporary object is introduced
|
| 181 |
+
if needed
|
| 182 |
[[dcl.type]], [[lex.literal]], [[lex.string]], [[dcl.array]], [[class.temporary]].
|
| 183 |
In addition, it is possible to modify the values of non-constant objects
|
| 184 |
through pointer parameters. — *end note*]
|
| 185 |
|
| 186 |
A function can be declared to accept fewer arguments (by declaring
|
|
|
|
| 206 |
function-to-pointer [[conv.func]] standard conversions are performed on
|
| 207 |
the argument expression. An argument that has type cv `std::nullptr_t`
|
| 208 |
is converted to type `void*` [[conv.ptr]]. After these conversions, if
|
| 209 |
the argument does not have arithmetic, enumeration, pointer,
|
| 210 |
pointer-to-member, or class type, the program is ill-formed. Passing a
|
| 211 |
+
potentially-evaluated argument of a scoped enumeration type [[dcl.enum]]
|
| 212 |
+
or of a class type [[class]] having an eligible non-trivial copy
|
| 213 |
+
constructor [[special]], [[class.copy.ctor]], an eligible non-trivial
|
| 214 |
+
move constructor, or a non-trivial destructor [[class.dtor]], with no
|
| 215 |
+
corresponding parameter, is conditionally-supported with
|
| 216 |
+
*implementation-defined* semantics. If the argument has integral or
|
| 217 |
enumeration type that is subject to the integral promotions
|
| 218 |
[[conv.prom]], or a floating-point type that is subject to the
|
| 219 |
floating-point promotion [[conv.fpprom]], the value of the argument is
|
| 220 |
converted to the promoted type before the call. These promotions are
|
| 221 |
referred to as the *default argument promotions*.
|
|
|
|
| 223 |
Recursive calls are permitted, except to the `main` function
|
| 224 |
[[basic.start.main]].
|
| 225 |
|
| 226 |
A function call is an lvalue if the result type is an lvalue reference
|
| 227 |
type or an rvalue reference to function type, an xvalue if the result
|
| 228 |
+
type is an rvalue reference to object type, and a prvalue otherwise. If
|
| 229 |
+
it is a non-void prvalue, the type of the function call expression shall
|
| 230 |
+
be complete, except as specified in [[dcl.type.decltype]].
|
| 231 |
|