When resolving a placeholder for a deduced class type (
[dcl.type.class.deduct])
where the
template-name names a primary class template
C,
a set of functions and function templates, called the guides of
C,
is formed comprising:
If
C is defined,
for each constructor of
C,
a function template with the following properties:
The template parameters are the template parameters of
C
followed
by the template parameters (including default template arguments) of the constructor,
if any
.The types of the function parameters are those of the constructor
.The return type is the class template specialization
designated by
C
and template arguments
corresponding to the template parameters of
C.
If
C
is not defined or does not declare any constructors,
an additional function template derived as above
from a hypothetical constructor
C().For each
deduction-guide,
a function or function template
with the following properties:
The template parameters, if any,
and function parameters
are those of the
deduction-guide.
In addition, if
C is defined
and its definition satisfies the conditions for
an aggregate class (
[dcl.init.aggr])
with the assumption that any dependent base class has
no virtual functions and no virtual base classes, and
the initializer is a non-empty
braced-init-list or
parenthesized
expression-list, and
there are no
deduction-guides for
C,
the set contains an additional function template,
called the
aggregate deduction candidate, defined as follows
. For each
xi, let
ei be the corresponding aggregate element
of
C or of one of its (possibly recursive) subaggregates
that would be initialized by
xi (
[dcl.init.aggr]) if
- brace elision is not considered for any aggregate element
that has
- a dependent non-array type,
- an array type with a value-dependent bound, or
- an array type with a dependent array element type and xi is a string literal; and
- each non-trailing aggregate element that is a pack expansion
is assumed to correspond to no elements of the initializer list, and
- a trailing aggregate element that is a pack expansion is assumed to correspond
to all remaining elements of the initializer list (if any).
If there is no such aggregate element
ei for any
xi,
the aggregate deduction candidate is not added to the set
. The aggregate deduction candidate is derived as above
from a hypothetical constructor
C(T1,…,Tn),
where
- if ei is of array type and
xi is a braced-init-list,
Ti is an rvalue reference to the declared type of ei, and
- if ei is of array type and
xi is a string-literal,
Ti is an lvalue reference to
the const-qualified declared type of ei, and
- otherwise, Ti is the declared type of ei,
except that additional parameter packs of the form
Pj...
are inserted into the parameter list in their original aggregate element position corresponding to each non-trailing aggregate element of type
Pj
that was skipped because it was a parameter pack, and
the trailing sequence of parameters corresponding
to a trailing aggregate element that is a pack expansion (if any)
is replaced by a single parameter of the form
Tn.... If
A is a deducible template (
[dcl.type.simple]),
the set contains the guides of
A
with the return type
R of each guide
replaced with
typename CC<R>::type given a class template
template <typename> class CC;
whose primary template is not defined and
with a single partial specialization
whose template parameter list is that of
A and
whose template argument list is a specialization of
A with
the template argument list of
A (
[temp.dep.type])
having a member typedef
type designating a template specialization with
the template argument list of
A but
with
C as the template
. [
Note 1:
Equivalently,
the template parameter list of the specialization is that of
C,
the template argument list of the specialization is
B, and
the member typedef names
C with the template argument list of
C. —
end note]