|
1673 | 1673 |
|
1674 | 1674 | \begin{bnf}
|
1675 | 1675 | \nontermdef{lambda-expression}\br
|
1676 |
| - lambda-introducer lambda-declarator compound-statement\br |
1677 |
| - lambda-introducer \terminal{<} template-parameter-list \terminal{>} \opt{requires-clause} lambda-declarator compound-statement |
| 1676 | + lambda-introducer \opt{attribute-specifier-seq} lambda-declarator compound-statement\br |
| 1677 | + lambda-introducer \terminal{<} template-parameter-list \terminal{>} \opt{requires-clause} \opt{attribute-specifier-seq}\br |
| 1678 | + \bnfindent lambda-declarator compound-statement |
1678 | 1679 | \end{bnf}
|
1679 | 1680 |
|
1680 | 1681 | \begin{bnf}
|
|
1684 | 1685 |
|
1685 | 1686 | \begin{bnf}
|
1686 | 1687 | \nontermdef{lambda-declarator}\br
|
1687 |
| - lambda-specifiers\br |
1688 |
| - \terminal{(} parameter-declaration-clause \terminal{)} lambda-specifiers \opt{requires-clause} |
1689 |
| -\end{bnf} |
1690 |
| - |
1691 |
| -\begin{bnf} |
1692 |
| -\nontermdef{lambda-specifiers}\br |
1693 |
| - \opt{lambda-specifier-seq} \opt{noexcept-specifier} \opt{attribute-specifier-seq} \opt{trailing-return-type} |
| 1688 | + lambda-specifier-seq \opt{noexcept-specifier} \opt{attribute-specifier-seq} \opt{trailing-return-type}\br |
| 1689 | + noexcept-specifier \opt{attribute-specifier-seq} \opt{trailing-return-type}\br |
| 1690 | + \opt{trailing-return-type}\br |
| 1691 | + \terminal{(} parameter-declaration-clause \terminal{)} \opt{lambda-specifier-seq} \opt{noexcept-specifier} \opt{attribute-specifier-seq}\br |
| 1692 | + \bnfindent \opt{trailing-return-type} \opt{requires-clause} |
1694 | 1693 | \end{bnf}
|
1695 | 1694 |
|
1696 | 1695 | \begin{bnf}
|
|
1727 | 1726 | object\iref{function.objects}.
|
1728 | 1727 | \end{note}
|
1729 | 1728 |
|
| 1729 | +\pnum |
| 1730 | +An ambiguity can arise |
| 1731 | +because a \grammarterm{requires-clause} can end in |
| 1732 | +an \grammarterm{attribute-specifier-seq}, |
| 1733 | +which collides with |
| 1734 | +the \grammarterm{attribute-specifier-seq} in \grammarterm{lambda-expression}. |
| 1735 | +In such cases, |
| 1736 | +any attributes are treated as |
| 1737 | +\grammarterm{attribute-specifier-seq} in \grammarterm{lambda-expression}. |
| 1738 | +\begin{note} |
| 1739 | +Such ambiguous cases cannot have valid semantics |
| 1740 | +because the constraint expression would not have type \keyword{bool}. |
| 1741 | +\end{note} |
| 1742 | + |
1730 | 1743 | \pnum
|
1731 | 1744 | A \grammarterm{lambda-specifier-seq}
|
1732 | 1745 | shall contain at most one of each \grammarterm{lambda-specifier} and
|
|
1740 | 1753 | \end{note}
|
1741 | 1754 |
|
1742 | 1755 | \pnum
|
1743 |
| -If a \grammarterm{lambda-expression} includes an empty |
1744 |
| -\grammarterm{lambda-declarator}, it is as if the \grammarterm{lambda-declarator} were |
1745 |
| -\tcode{()}. |
1746 |
| -The lambda return type is \keyword{auto}, which is replaced by the |
1747 |
| -type specified by the |
1748 |
| -\grammarterm{trailing-return-type} if provided and/or deduced from |
1749 |
| -\tcode{return} statements as described in~\ref{dcl.spec.auto}. |
| 1756 | +If a \grammarterm{lambda-declarator} does not include |
| 1757 | +a \grammarterm{parameter-declaration-clause}, |
| 1758 | +it is as if \tcode{()} were inserted |
| 1759 | +at the start of the \grammarterm{lambda-declarator}. |
| 1760 | +If the \grammarterm{lambda-declarator} |
| 1761 | +does not include a \grammarterm{trailing-return-type}, |
| 1762 | +the lambda return type is \keyword{auto}, |
| 1763 | +which is deduced from \keyword{return} statements |
| 1764 | +as described in \ref{dcl.spec.auto}. |
1750 | 1765 | \begin{example}
|
1751 | 1766 | \begin{codeblock}
|
1752 | 1767 | auto x1 = [](int i) { return i; }; // OK, return type is \tcode{int}
|
|
1888 | 1903 | applies to the corresponding function call operator or operator template.
|
1889 | 1904 | An \grammarterm{attribute-specifier-seq} in a \grammarterm{lambda-declarator} appertains
|
1890 | 1905 | to the type of the corresponding function call operator or operator template.
|
| 1906 | +An \grammarterm{attribute-specifier-seq} in a \grammarterm{lambda-expression} |
| 1907 | +preceding a \grammarterm{lambda-declarator} |
| 1908 | +appertains to the corresponding function call operator or operator template. |
1891 | 1909 | The function call operator or any given operator template specialization
|
1892 | 1910 | is a constexpr function if either
|
1893 | 1911 | the corresponding \grammarterm{lambda-expression}{'s}
|
|
0 commit comments