|
1604 | 1604 | the type of such an identifier will typically be \keyword{const} qualified. |
1605 | 1605 | \end{note} |
1606 | 1606 |
|
| 1607 | +\begin{example} |
| 1608 | +\begin{codeblock} |
| 1609 | +void f() { |
| 1610 | + float x, &r = x; |
| 1611 | + |
| 1612 | + [=]() -> decltype((x)) { // lambda returns \tcode{float const\&} because this lambda is not \tcode{mutable} and |
| 1613 | + // \tcode{x} is an lvalue |
| 1614 | + decltype(x) y1; // \tcode{y1} has type \tcode{float} |
| 1615 | + decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} |
| 1616 | + decltype(r) r1 = y1; // \tcode{r1} has type \tcode{float\&} |
| 1617 | + decltype((r)) r2 = y2; // \tcode{r2} has type \tcode{float const\&} |
| 1618 | + return y2; |
| 1619 | + }; |
| 1620 | + |
| 1621 | + [=](decltype((x)) y) { |
| 1622 | + decltype((x)) z = x; // OK, \tcode{y} has type \tcode{float\&}, \tcode{z} has type \tcode{float const\&} |
| 1623 | + }; |
| 1624 | + |
| 1625 | + [=] { |
| 1626 | + [](decltype((x)) y) {}; // OK, lambda takes a parameter of type \tcode{float const\&} |
| 1627 | + |
| 1628 | + [x=1](decltype((x)) y) { |
| 1629 | + decltype((x)) z = x; // OK, \tcode{y} has type \tcode{int\&}, \tcode{z} has type \tcode{int const\&} |
| 1630 | + }; |
| 1631 | + }; |
| 1632 | +} |
| 1633 | +\end{codeblock} |
| 1634 | +\end{example} |
| 1635 | + |
1607 | 1636 | \pnum |
1608 | 1637 | Otherwise, |
1609 | 1638 | if the \grammarterm{unqualified-id} |
|
1762 | 1791 | is sequenced before the initialization of the result object\iref{expr.call}, |
1763 | 1792 | $E$ refers to the most recently initialized such temporary object. |
1764 | 1793 |
|
1765 | | - |
1766 | | -\begin{example} |
1767 | | -\begin{codeblock} |
1768 | | -void f() { |
1769 | | - float x, &r = x; |
1770 | | - |
1771 | | - [=]() -> decltype((x)) { // lambda returns \tcode{float const\&} because this lambda is not \tcode{mutable} and |
1772 | | - // \tcode{x} is an lvalue |
1773 | | - decltype(x) y1; // \tcode{y1} has type \tcode{float} |
1774 | | - decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} |
1775 | | - decltype(r) r1 = y1; // \tcode{r1} has type \tcode{float\&} |
1776 | | - decltype((r)) r2 = y2; // \tcode{r2} has type \tcode{float const\&} |
1777 | | - return y2; |
1778 | | - }; |
1779 | | - |
1780 | | - [=](decltype((x)) y) { |
1781 | | - decltype((x)) z = x; // OK, \tcode{y} has type \tcode{float\&}, \tcode{z} has type \tcode{float const\&} |
1782 | | - }; |
1783 | | - |
1784 | | - [=] { |
1785 | | - [](decltype((x)) y) {}; // OK, lambda takes a parameter of type \tcode{float const\&} |
1786 | | - |
1787 | | - [x=1](decltype((x)) y) { |
1788 | | - decltype((x)) z = x; // OK, \tcode{y} has type \tcode{int\&}, \tcode{z} has type \tcode{int const\&} |
1789 | | - }; |
1790 | | - }; |
1791 | | -} |
1792 | | -\end{codeblock} |
1793 | | -\end{example} |
1794 | | - |
1795 | 1794 | \pnum |
1796 | 1795 | An \defnadj{implicitly movable}{entity} is |
1797 | 1796 | a variable with automatic storage duration |
|
0 commit comments