A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/temp.deduct.guide below:

[temp.deduct.guide]

17 Templates [temp] 17.9 Deduction guides [temp.deduct.guide] 1 #

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 ;
2 #

[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]

3 #

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4