Zitate aus der C++-Norm (Zitate aus der C++-Norm), Lektion, Seite 724254
https://www.purl.org/stefan_ram/pub/normzitate_c++ (Permalink) ist die kanonische URI dieser Seite.
Stefan Ram
C++-Kurs

Zitate aus der C++ -Norm

In Zusammenhang mit Wertreferenzen

Referenzkollabierung

& + & = &

&& + & = &

& + && = &

&& + && = &&

Zitat
If a typedef-name (9.1.3, 12.1) or a decltype-specifier (9.1.7.2) denotes a type TR that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T”, while an attempt to create the type “rvalue reference to cv TR” creates the type TR.
9.2.3.2 References [dcl.ref] p6

Ein Schablonenparameter gilt dabei als typedef-name!

Zitat
A type-parameter whose identifier does not follow an ellipsis defines its identifier to be a typedef-name (if declared without template) or template-name (if declared with template) in the scope of the template declaration.
N4762 12.1 Template parameters [temp.param] p3 s1

In Zusammenhang mit Schablonen

Ein Schablonenparameter ist ein typedef-name

Zitat
A type-parameter whose identifier does not follow an ellipsis defines its identifier to be a typedef-name (if declared without template) or template-name (if declared with template) in the scope of the template declaration.
N4762 12.1 Template parameters [temp.param] p3 s1

In Zusammenhang mit Weiterleitungsreferenzen

Definition von „Weiterleitungsreferenz“

Zitat
A forwarding reference is an rvalue reference to a cv-unqualified template parameter that does not represent a template parameter of a class template
N4762 12.9.2.1 Deducing template arguments from a function call [temp.deduct.call] p3 s3

Variablen als Argumente

Beispiel
int a {}; f( a )
Zitat
If P is a forwarding reference and the argument is an lvalue, the type "lvalue reference to A" is used in place of A for type deduction.
N4762 12.9.2.1 Deducing template arguments from a function call [temp.deduct.call] p3 s4

Referenzkollabierung

The exceptions, the circumstances where T && can be deduced from U &, are done by changing T && to plain T before the matching takes place, in limited circumstances:

paragraph 3 gives the deduction of rvalue references special treatment in the context of a function call:

17.9.2.1 [temp.deduct.call] paragraph 3 gives the deduction of rvalue references special treatment in the context of a function call:

If P is of the form T&&, where T is a template parameter, and the argument is an lvalue, the type A& is used in place of A for type deduction. A similar provision is needed, but is not present, in declarative contexts. For example:

template<typename T> void f(T&&);

template<> void f(int&) { } // #1

template<> void f(int&&) { } // #2

void g(int i) {

f(i); // calls f<int&>(int&), i.e., #1

f(0); // calls f<int>(int&&), i.e., #2

}

There need to be rules that deduce the template arguments for the specializations in the same way that the arguments are deduced in the calls.

Zitat
If P and A are function types that originated from deduction when taking the address of a function template (12.9.2.2) or when deducing template arguments from a function declaration (12.9.2.6) and Pi and Ai are parameters of the top-level parameter-type-list of P and A, respectively, Pi is adjusted if it is a forwarding reference (12.9.2.1) and Ai is an lvalue reference, in which case the type of Pi is changed to be the template parameter type (i.e., T&& is changed to simply T).
N4762 12.9.2.5 Deducing template arguments from a type [temp.deduct.type] p10

 

Seiteninformationen und Impressum   |   Mitteilungsformular  |   "ram@zedat.fu-berlin.de" (ohne die Anführungszeichen) ist die Netzpostadresse von Stefan Ram.   |   Eine Verbindung zur Stefan-Ram-Startseite befindet sich oben auf dieser Seite hinter dem Text "Stefan Ram".)  |   Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram. Schlüsselwörter zu dieser Seite/relevant keywords describing this page: Stefan Ram Berlin slrprd slrprd stefanramberlin spellched stefanram724254 stefan_ram:724254 Zitate aus der C++-Norm Stefan Ram, Berlin, and, or, near, uni, online, slrprd, slrprdqxx, slrprddoc, slrprd724254, slrprddef724254, PbclevtugFgrsnaEnz Erklärung, Beschreibung, Info, Information, Hinweis,

Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram.
https://www.purl.org/stefan_ram/pub/normzitate_c++