Skip to content

Commit 19a6687

Browse files
jensmaurerzygoloid
authored andcommitted
[temp.deduct.guide] Move into [temp.class].
Deduction guides apply only to class templates, so their descriptions should be located in close proximity.
1 parent 5fb67e4 commit 19a6687

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

source/templates.tex

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,62 @@
22972297
\end{codeblock}
22982298
\end{example}
22992299

2300+
\rSec3[temp.deduct.guide]{Deduction guides}
2301+
\indextext{deduction!class template argument}%
2302+
2303+
\pnum
2304+
Deduction guides are used
2305+
when a \grammarterm{template-name} appears
2306+
as a type specifier
2307+
for a deduced class type\iref{dcl.type.class.deduct}.
2308+
Deduction guides are not found by name lookup.
2309+
Instead, when performing class template argument deduction\iref{over.match.class.deduct},
2310+
any deduction guides declared for the class template are considered.
2311+
2312+
\begin{bnf}
2313+
\nontermdef{deduction-guide}\br
2314+
\opt{explicit-specifier} template-name \terminal{(} parameter-declaration-clause \terminal{)} \terminal{->} simple-template-id \terminal{;}
2315+
\end{bnf}
2316+
2317+
\pnum
2318+
\begin{example}
2319+
\begin{codeblock}
2320+
template<class T, class D = int>
2321+
struct S {
2322+
T data;
2323+
};
2324+
template<class U>
2325+
S(U) -> S<typename U::type>;
2326+
2327+
struct A {
2328+
using type = short;
2329+
operator type();
2330+
};
2331+
S x{A()}; // \tcode{x} is of type \tcode{S<short, int>}
2332+
\end{codeblock}
2333+
\end{example}
2334+
2335+
\pnum
2336+
The same restrictions apply
2337+
to the \grammarterm{parameter-declaration-clause}
2338+
of a deduction guide
2339+
as in a function declaration\iref{dcl.fct}.
2340+
The \grammarterm{simple-template-id}
2341+
shall name a class template specialization.
2342+
The \grammarterm{template-name}
2343+
shall be the same \grammarterm{identifier}
2344+
as the \grammarterm{template-name}
2345+
of the \grammarterm{simple-template-id}.
2346+
A \grammarterm{deduction-guide}
2347+
shall be declared
2348+
in the same scope
2349+
as the corresponding class template
2350+
and, for a member class template, with the same access.
2351+
Two deduction guide declarations
2352+
in the same translation unit
2353+
for the same class template
2354+
shall not have equivalent \grammarterm{parameter-declaration-clause}{s}.
2355+
23002356
\rSec3[temp.mem.class]{Member classes of class templates}
23012357

23022358
\pnum
@@ -8999,60 +9055,4 @@
89999055
is present in some translation unit.
90009056
\end{example}
90019057

9002-
\rSec1[temp.deduct.guide]{Deduction guides}
9003-
\indextext{deduction!class template argument}%
9004-
9005-
\pnum
9006-
Deduction guides are used
9007-
when a \grammarterm{template-name} appears
9008-
as a type specifier
9009-
for a deduced class type\iref{dcl.type.class.deduct}.
9010-
Deduction guides are not found by name lookup.
9011-
Instead, when performing class template argument deduction\iref{over.match.class.deduct},
9012-
any deduction guides declared for the class template are considered.
9013-
9014-
\begin{bnf}
9015-
\nontermdef{deduction-guide}\br
9016-
\opt{explicit-specifier} template-name \terminal{(} parameter-declaration-clause \terminal{)} \terminal{->} simple-template-id \terminal{;}
9017-
\end{bnf}
9018-
9019-
\pnum
9020-
\begin{example}
9021-
\begin{codeblock}
9022-
template<class T, class D = int>
9023-
struct S {
9024-
T data;
9025-
};
9026-
template<class U>
9027-
S(U) -> S<typename U::type>;
9028-
9029-
struct A {
9030-
using type = short;
9031-
operator type();
9032-
};
9033-
S x{A()}; // \tcode{x} is of type \tcode{S<short, int>}
9034-
\end{codeblock}
9035-
\end{example}
9036-
9037-
\pnum
9038-
The same restrictions apply
9039-
to the \grammarterm{parameter-declaration-clause}
9040-
of a deduction guide
9041-
as in a function declaration\iref{dcl.fct}.
9042-
The \grammarterm{simple-template-id}
9043-
shall name a class template specialization.
9044-
The \grammarterm{template-name}
9045-
shall be the same \grammarterm{identifier}
9046-
as the \grammarterm{template-name}
9047-
of the \grammarterm{simple-template-id}.
9048-
A \grammarterm{deduction-guide}
9049-
shall be declared
9050-
in the same scope
9051-
as the corresponding class template
9052-
and, for a member class template, with the same access.
9053-
Two deduction guide declarations
9054-
in the same translation unit
9055-
for the same class template
9056-
shall not have equivalent \grammarterm{parameter-declaration-clause}{s}.
9057-
90589058
\indextext{template|)}

0 commit comments

Comments
 (0)