Deduction guides are used when a template-name appears as a type specifier for a deduced class type. Deduction guides are not found by name lookup. Instead, when performing class template argument deduction, any deduction guides declared for the class template are considered.
deduction-guide: explicitopt template-name ( parameter-declaration-clause ) -> simple-template-id ;
[ Example:
template<class T, class D = int>
struct S {
T data;
};
template<class U>
S(U) -> S<typename U::type>;
struct A {
using type = short;
operator type();
};
S x{A()}; // x is of type S<short, int>
— end example ]
The same restrictions apply to the parameter-declaration-clause of a deduction guide as in a function declaration ([dcl.fct]). The simple-template-id shall name a class template specialization. The template-name shall be the same identifier as the template-name of the simple-template-id. A deduction-guide shall be declared in the same scope as the corresponding class template and, for a member class template, with the same access. Two deduction guide declarations in the same translation unit for the same class template shall not have equivalent parameter-declaration-clauses.