|
1592 | 1592 | the type of such an identifier will typically be \keyword{const} qualified. |
1593 | 1593 | \end{note} |
1594 | 1594 |
|
| 1595 | +\begin{example} |
| 1596 | +\begin{codeblock} |
| 1597 | +void f() { |
| 1598 | + float x, &r = x; |
| 1599 | + |
| 1600 | + [=]() -> decltype((x)) { // lambda returns \tcode{float const\&} because this lambda is not \tcode{mutable} and |
| 1601 | + // \tcode{x} is an lvalue |
| 1602 | + decltype(x) y1; // \tcode{y1} has type \tcode{float} |
| 1603 | + decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} |
| 1604 | + decltype(r) r1 = y1; // \tcode{r1} has type \tcode{float\&} |
| 1605 | + decltype((r)) r2 = y2; // \tcode{r2} has type \tcode{float const\&} |
| 1606 | + return y2; |
| 1607 | + }; |
| 1608 | + |
| 1609 | + [=](decltype((x)) y) { |
| 1610 | + decltype((x)) z = x; // OK, \tcode{y} has type \tcode{float\&}, \tcode{z} has type \tcode{float const\&} |
| 1611 | + }; |
| 1612 | + |
| 1613 | + [=] { |
| 1614 | + [](decltype((x)) y) {}; // OK, lambda takes a parameter of type \tcode{float const\&} |
| 1615 | + |
| 1616 | + [x=1](decltype((x)) y) { |
| 1617 | + decltype((x)) z = x; // OK, \tcode{y} has type \tcode{int\&}, \tcode{z} has type \tcode{int const\&} |
| 1618 | + }; |
| 1619 | + }; |
| 1620 | +} |
| 1621 | +\end{codeblock} |
| 1622 | +\end{example} |
| 1623 | + |
1595 | 1624 | \pnum |
1596 | 1625 | Otherwise, |
1597 | 1626 | if the \grammarterm{unqualified-id} |
|
1750 | 1779 | is sequenced before the initialization of the result object\iref{expr.call}, |
1751 | 1780 | $E$ refers to the most recently initialized such temporary object. |
1752 | 1781 |
|
1753 | | - |
1754 | | -\begin{example} |
1755 | | -\begin{codeblock} |
1756 | | -void f() { |
1757 | | - float x, &r = x; |
1758 | | - |
1759 | | - [=]() -> decltype((x)) { // lambda returns \tcode{float const\&} because this lambda is not \tcode{mutable} and |
1760 | | - // \tcode{x} is an lvalue |
1761 | | - decltype(x) y1; // \tcode{y1} has type \tcode{float} |
1762 | | - decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} |
1763 | | - decltype(r) r1 = y1; // \tcode{r1} has type \tcode{float\&} |
1764 | | - decltype((r)) r2 = y2; // \tcode{r2} has type \tcode{float const\&} |
1765 | | - return y2; |
1766 | | - }; |
1767 | | - |
1768 | | - [=](decltype((x)) y) { |
1769 | | - decltype((x)) z = x; // OK, \tcode{y} has type \tcode{float\&}, \tcode{z} has type \tcode{float const\&} |
1770 | | - }; |
1771 | | - |
1772 | | - [=] { |
1773 | | - [](decltype((x)) y) {}; // OK, lambda takes a parameter of type \tcode{float const\&} |
1774 | | - |
1775 | | - [x=1](decltype((x)) y) { |
1776 | | - decltype((x)) z = x; // OK, \tcode{y} has type \tcode{int\&}, \tcode{z} has type \tcode{int const\&} |
1777 | | - }; |
1778 | | - }; |
1779 | | -} |
1780 | | -\end{codeblock} |
1781 | | -\end{example} |
1782 | | - |
1783 | 1782 | \pnum |
1784 | 1783 | An \defnadj{implicitly movable}{entity} is |
1785 | 1784 | a variable with automatic storage duration |
|
0 commit comments