tmp/tmpxenm4pn5/{from.md → to.md}
RENAMED
|
@@ -13,14 +13,15 @@ lambda-introducer:
|
|
| 13 |
```
|
| 14 |
|
| 15 |
``` bnf
|
| 16 |
lambda-declarator:
|
| 17 |
lambda-specifier-seq noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ trailing-return-typeₒₚₜ
|
| 18 |
-
|
| 19 |
-
trailing-return-typeₒₚₜ
|
|
|
|
| 20 |
'(' parameter-declaration-clause ')' lambda-specifier-seqₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
|
| 21 |
-
trailing-return-typeₒₚₜ requires-clauseₒₚₜ
|
| 22 |
```
|
| 23 |
|
| 24 |
``` bnf
|
| 25 |
lambda-specifier:
|
| 26 |
consteval
|
|
@@ -29,12 +30,11 @@ lambda-specifier:
|
|
| 29 |
static
|
| 30 |
```
|
| 31 |
|
| 32 |
``` bnf
|
| 33 |
lambda-specifier-seq:
|
| 34 |
-
lambda-specifier
|
| 35 |
-
lambda-specifier lambda-specifier-seq
|
| 36 |
```
|
| 37 |
|
| 38 |
A *lambda-expression* provides a concise way to create a simple function
|
| 39 |
object.
|
| 40 |
|
|
@@ -60,12 +60,24 @@ An ambiguity can arise because a *requires-clause* can end in an
|
|
| 60 |
*attribute-specifier-seq*, which collides with the
|
| 61 |
*attribute-specifier-seq* in *lambda-expression*. In such cases, any
|
| 62 |
attributes are treated as *attribute-specifier-seq* in
|
| 63 |
*lambda-expression*.
|
| 64 |
|
| 65 |
-
[*Note 2*:
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
A *lambda-specifier-seq* shall contain at most one of each
|
| 69 |
*lambda-specifier* and shall not contain both `constexpr` and
|
| 70 |
`consteval`. If the *lambda-declarator* contains an explicit object
|
| 71 |
parameter [[dcl.fct]], then no *lambda-specifier* in the
|
|
@@ -75,19 +87,20 @@ the *lambda-specifier-seq* contains `static`, there shall be no
|
|
| 75 |
*lambda-capture*.
|
| 76 |
|
| 77 |
[*Note 3*: The trailing *requires-clause* is described in
|
| 78 |
[[dcl.decl]]. — *end note*]
|
| 79 |
|
| 80 |
-
|
| 81 |
-
*parameter-declaration-clause*
|
| 82 |
-
|
| 83 |
-
include a *trailing-return-type*, it is
|
|
|
|
| 84 |
|
| 85 |
[*Note 4*: In that case, the return type is deduced from `return`
|
| 86 |
statements as described in [[dcl.spec.auto]]. — *end note*]
|
| 87 |
|
| 88 |
-
[*Example
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
auto x1 = [](int i) { return i; }; // OK, return type is int
|
| 92 |
auto x2 = []{ return { 1, 2 }; }; // error: deducing return type from braced-init-list
|
| 93 |
int j;
|
|
@@ -98,14 +111,15 @@ auto x3 = [&]()->auto&& { return j; }; // OK, return type is int&
|
|
| 98 |
|
| 99 |
A lambda is a *generic lambda* if the *lambda-expression* has any
|
| 100 |
generic parameter type placeholders [[dcl.spec.auto]], or if the lambda
|
| 101 |
has a *template-parameter-list*.
|
| 102 |
|
| 103 |
-
[*Example
|
| 104 |
|
| 105 |
``` cpp
|
| 106 |
-
|
| 107 |
-
|
|
|
|
| 108 |
```
|
| 109 |
|
| 110 |
— *end example*]
|
| 111 |
|
|
|
|
| 13 |
```
|
| 14 |
|
| 15 |
``` bnf
|
| 16 |
lambda-declarator:
|
| 17 |
lambda-specifier-seq noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ trailing-return-typeₒₚₜ
|
| 18 |
+
function-contract-specifier-seqₒₚₜ
|
| 19 |
+
noexcept-specifier attribute-specifier-seqₒₚₜ trailing-return-typeₒₚₜ function-contract-specifier-seqₒₚₜ
|
| 20 |
+
trailing-return-typeₒₚₜ function-contract-specifier-seqₒₚₜ
|
| 21 |
'(' parameter-declaration-clause ')' lambda-specifier-seqₒₚₜ noexcept-specifierₒₚₜ attribute-specifier-seqₒₚₜ
|
| 22 |
+
trailing-return-typeₒₚₜ requires-clauseₒₚₜ function-contract-specifier-seqₒₚₜ
|
| 23 |
```
|
| 24 |
|
| 25 |
``` bnf
|
| 26 |
lambda-specifier:
|
| 27 |
consteval
|
|
|
|
| 30 |
static
|
| 31 |
```
|
| 32 |
|
| 33 |
``` bnf
|
| 34 |
lambda-specifier-seq:
|
| 35 |
+
lambda-specifier lambda-specifier-seqₒₚₜ
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
A *lambda-expression* provides a concise way to create a simple function
|
| 39 |
object.
|
| 40 |
|
|
|
|
| 60 |
*attribute-specifier-seq*, which collides with the
|
| 61 |
*attribute-specifier-seq* in *lambda-expression*. In such cases, any
|
| 62 |
attributes are treated as *attribute-specifier-seq* in
|
| 63 |
*lambda-expression*.
|
| 64 |
|
| 65 |
+
[*Note 2*:
|
| 66 |
+
|
| 67 |
+
Such ambiguous cases cannot have valid semantics because the constraint
|
| 68 |
+
expression would not have type `bool`.
|
| 69 |
+
|
| 70 |
+
[*Example 2*:
|
| 71 |
+
|
| 72 |
+
``` cpp
|
| 73 |
+
auto x = []<class T> requires T::operator int [[some_attribute]] (int) { }
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
— *end example*]
|
| 77 |
+
|
| 78 |
+
— *end note*]
|
| 79 |
|
| 80 |
A *lambda-specifier-seq* shall contain at most one of each
|
| 81 |
*lambda-specifier* and shall not contain both `constexpr` and
|
| 82 |
`consteval`. If the *lambda-declarator* contains an explicit object
|
| 83 |
parameter [[dcl.fct]], then no *lambda-specifier* in the
|
|
|
|
| 87 |
*lambda-capture*.
|
| 88 |
|
| 89 |
[*Note 3*: The trailing *requires-clause* is described in
|
| 90 |
[[dcl.decl]]. — *end note*]
|
| 91 |
|
| 92 |
+
A *lambda-expression*'s *parameter-declaration-clause* is the
|
| 93 |
+
*parameter-declaration-clause* of the *lambda-expression*'s
|
| 94 |
+
*lambda-declarator*, if any, or empty otherwise. If the
|
| 95 |
+
*lambda-declarator* does not include a *trailing-return-type*, it is
|
| 96 |
+
considered to be `-> auto`.
|
| 97 |
|
| 98 |
[*Note 4*: In that case, the return type is deduced from `return`
|
| 99 |
statements as described in [[dcl.spec.auto]]. — *end note*]
|
| 100 |
|
| 101 |
+
[*Example 3*:
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
auto x1 = [](int i) { return i; }; // OK, return type is int
|
| 105 |
auto x2 = []{ return { 1, 2 }; }; // error: deducing return type from braced-init-list
|
| 106 |
int j;
|
|
|
|
| 111 |
|
| 112 |
A lambda is a *generic lambda* if the *lambda-expression* has any
|
| 113 |
generic parameter type placeholders [[dcl.spec.auto]], or if the lambda
|
| 114 |
has a *template-parameter-list*.
|
| 115 |
|
| 116 |
+
[*Example 4*:
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
+
auto x = [](int i, auto a) { return i; }; // OK, a generic lambda
|
| 120 |
+
auto y = [](this auto self, int i) { return i; }; // OK, a generic lambda
|
| 121 |
+
auto z = []<class T>(int i) { return i; }; // OK, a generic lambda
|
| 122 |
```
|
| 123 |
|
| 124 |
— *end example*]
|
| 125 |
|