Skip to content

Commit b279129

Browse files
authored
[expr.prim.id.unqual] Fix misplaced example
1 parent 940a063 commit b279129

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
@@ -1592,6 +1592,35 @@
15921592
the type of such an identifier will typically be \keyword{const} qualified.
15931593
\end{note}
15941594

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+
15951624
\pnum
15961625
Otherwise,
15971626
if the \grammarterm{unqualified-id}
@@ -1750,36 +1779,6 @@
17501779
is sequenced before the initialization of the result object\iref{expr.call},
17511780
$E$ refers to the most recently initialized such temporary object.
17521781

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

0 commit comments

Comments
 (0)