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/dcl.type.auto.deduct below:

[dcl.type.auto.deduct]

10 Declarations [dcl.dcl] 10.1 Specifiers [dcl.spec] 10.1.7 Type specifiers [dcl.type] 10.1.7.4 The auto specifier [dcl.spec.auto] 10.1.7.4.1 Placeholder type deduction [dcl.type.auto.deduct]

A type T containing a placeholder type, and a corresponding initializer e, are determined as follows:

In the case of a return statement with no operand or with an operand of type void, T shall be either decltype(auto) or cv auto.

If the placeholder is the auto type-specifier, the deduced type T' replacing T is determined using the rules for template argument deduction. Obtain P from T by replacing the occurrences of auto with either a new invented type template parameter U or, if the initialization is copy-list-initialization, with std​::​initializer_­list<U>. Deduce a value for U using the rules of template argument deduction from a function call, where P is a function template parameter type and the corresponding argument is e. If the deduction fails, the declaration is ill-formed. Otherwise, T' is obtained by substituting the deduced U into P. [Example:

auto x1 = { 1, 2 };             auto x2 = { 1, 2.0 };           auto x3{ 1, 2 };                auto x4 = { 3 };                auto x5{ 3 };                   

end example]

[Example:

const auto &i = expr;

The type of i is the deduced type of the parameter u in the call f(expr) of the following invented function template:

template <class U> void f(const U& u);

end example]

If the placeholder is the decltype(auto) type-specifier, T shall be the placeholder alone. The type deduced for T is determined as described in [dcl.type.simple], as though e had been the operand of the decltype. [Example:

int i;
int&& f();
auto           x2a(i);          decltype(auto) x2d(i);          auto           x3a = i;         decltype(auto) x3d = i;         auto           x4a = (i);       decltype(auto) x4d = (i);       auto           x5a = f();       decltype(auto) x5d = f();       auto           x6a = { 1, 2 };  decltype(auto) x6d = { 1, 2 };  auto          *x7a = &i;        decltype(auto)*x7d = &i;        

end example]


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