Skip to content

Commit dd1c71e

Browse files
cpplearnertkoeppe
authored andcommitted
[expr.prim.id.unqual] Fix misplaced example
1 parent 08ab900 commit dd1c71e

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

source/expressions.tex

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,35 @@
16041604
the type of such an identifier will typically be \keyword{const} qualified.
16051605
\end{note}
16061606

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+
16071636
\pnum
16081637
Otherwise,
16091638
if the \grammarterm{unqualified-id}
@@ -1762,36 +1791,6 @@
17621791
is sequenced before the initialization of the result object\iref{expr.call},
17631792
$E$ refers to the most recently initialized such temporary object.
17641793

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-
17951794
\pnum
17961795
An \defnadj{implicitly movable}{entity} is
17971796
a variable with automatic storage duration

0 commit comments

Comments
 (0)