Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


988. Reference-to-reference collapsing withdecltype

Section:9.2.9.3  [dcl.type.simple]    Status:CD2    Submitter:Michael Wong    Date:19 October, 2009

[Voted into WP at March, 2010 meeting.]

References to references are ill-formed, but special provision ismade in cases where this occurs via typedefs or template typeparameters. A similar provision is probably needed for types resultingfromdecltype:

    int x, *p = &x;    decltype(*p) &y = *p;  // reference to reference is ill-formed

Proposed resolution (October, 2009):

  1. Delete 9.2.4 [dcl.typedef] paragraph 9:

  2. If a typedefTD names a type that is a reference to atypeT, an attempt to create the type “lvalue referencetocvTD” creates the type “lvaluereference toT,” while an attempt to create the type“rvalue reference tocvTD” creates the typeTD. [Example: ... —end example]
  3. Delete 13.4.2 [temp.arg.type] paragraph 4:

  4. If atemplate-argument for atemplate-parameterT names a type that is a reference to a typeA, anattempt to create the type “lvalue reference tocvT” creates the type “lvalue reference toA,” while an attempt to create the type “rvaluereference tocvT” creates the typeT[Example: ... —end example]
  5. Add the following as a new paragraph at the end of 9.3.4.3 [dcl.ref]:

  6. If a typedef (9.2.4 [dcl.typedef]), a typetemplate-parameter (13.4.2 [temp.arg.type]), or adecltype-specifier (9.2.9.3 [dcl.type.simple]) denotes atypeTR that is a reference to a typeT, an attemptto create the type “lvalue reference tocvTR” creates the type “lvalue reference toT,” while an attempt to create the type “rvaluereference tocvTR” creates the typeTR. [Example:

       int i;   typedef int& LRI;   typedef int&& RRI;   LRI& r1 = i;                      // r1 has the typeint&   const LRI& r2 = i;                // r2 has the typeint&   const LRI&& r3 = i;               // r3 has the typeint&   RRI& r4 = i;                      // r4 has the typeint&   RRI&& r5 = i;                     // r5 has the typeint&&   decltype(r2)& r6 = i;             // r6 has the typeint&   decltype(r2)&& r7 = i;            // r7 has the typeint&

    end example]




[8]ページ先頭

©2009-2026 Movatter.jp