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:
for each constructor of C
a function template with the following properties:
The template parameters are the template parameters of C
by the template parameters (including default template arguments) of the constructor,
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.
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:
In addition, if C
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
there are no deduction-guides
the set contains an additional function template,
called the aggregate deduction candidate
, defined as follows.
be the corresponding aggregate element
or of one of its (possibly recursive) subaggregates
that would be initialized by
- brace elision is not considered for any aggregate element
that has a dependent non-array type or
an array type with a value-dependent bound, 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
the aggregate deduction candidate is not added to the set.
The aggregate deduction candidate is derived as above
from a hypothetical constructor
except that additional parameter packs of the form
are inserted into the parameter list in their original aggregate element position corresponding to each non-trailing aggregate element of type
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 .
The guides of A
are the set of functions or function templates
formed as follows.
For each function or function template f
in the guides of
the template named by the simple-template-id
of the defining-type-id
the template arguments of the return type of f
from the defining-type-id
according to the process in [temp.deduct.type]
with the exception that deduction does not fail
if not all template arguments are deduced.
denote the result of substituting
these deductions into f.
If substitution succeeds,
form a function or function template f'
with the following properties and add it to the set
of guides of A
The function type of f'
is the function type of g.
is a function template,
is a function template whose
template parameter list consists of
all the template parameters of A
(including their default template arguments)
that appear in the above deductions or
(recursively) in their default template arguments,
followed by the template parameters of f
that were not deduced
(including their default template arguments),
is not a function template.
The associated constraints ([temp.constr.decl]
the conjunction of the associated constraints of g
a constraint that is satisfied if and only if
the arguments of A
are deducible (see below) from the return type.
is a copy deduction candidate,
is considered to be so as well.
The arguments of a template A
are said to be
deducible from a type T
if, given a class template
template <typename> class AA;
with a single partial specialization
whose template parameter list is that of A
whose template argument list is a specialization of A
with the template argument list of A
matches the partial specialization.
Initialization and overload resolution are performed as described
(as appropriate for the type of initialization
performed) for an object of a hypothetical class type, where
the guides of the template named by the placeholder are considered to be the
constructors of that class type for the purpose of forming an overload
set, and the initializer is provided by the context in which class
template argument deduction was performed.
The following exceptions apply:
The first phase in [over.match.list]
(considering initializer-list constructors)
is omitted if the initializer list consists of
a single expression of type cv U
is, or is derived from,
a specialization of the class template
directly or indirectly named by the placeholder.
During template argument deduction for the aggregate deduction candidate,
the number of elements in a trailing parameter pack
is only deduced from the number of remaining function arguments
if it is not otherwise deduced.
All such notional constructors are considered to be
public members of the hypothetical class type.