<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 106</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="106"></A><H4>106.
  
Creating references to references during template deduction/instantiation
</H4>
<B>Section: </B>Clause unknown&#160; [<A href="https://wg21.link/unknown">unknown</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Bjarne Stroustrup
 &#160;&#160;&#160;

 <B>Date: </B>unknown<BR>



<P>[Moved to DR at 10/01 meeting.]</P>

<P>The main defect is in the library, where the binder template can
easily lead to reference-to-reference situations.</P>

<P><B>Proposed resolution (04/01):</B></P>

<OL>

<LI>
Add the following as paragraph 6 of 9.2.4 [<A href="https://wg21.link/dcl.typedef">dcl.typedef</A>]:

<BLOCKQUOTE>

<P>If a typedef <TT>TD</TT> names a type "reference to
<I>cv1</I> <TT>S</TT>," an attempt to create the type
"reference to <I>cv2</I> <TT>TD</TT>" creates the type
"reference to <I>cv12"</I> <TT>S</TT>," where <I>cv12</I> is the
union of the cv-qualifiers <I>cv1</I> and <I>cv2</I>.
Redundant qualifiers are ignored.  [<I>Example:</I>
</P>

<PRE>
    int i;
    typedef int&amp; RI;
    RI&amp; r = i;          // r <I>has the type</I> int&amp;
    const RI&amp; r = i;    // r <I>has the type</I> const int&amp;
</PRE>

&#8212;<I>end example</I>]
</BLOCKQUOTE>
</LI>

<LI>
Add the following as paragraph 4 of 13.4.2 [<A href="https://wg21.link/temp.arg.type">temp.arg.type</A>]:

<BLOCKQUOTE>

<P>If a <I>template-argument</I> for a <I>template-parameter</I>
<TT>T</TT> names a type "reference to <I>cv1</I> <TT>S</TT>,"
an attempt to create the type "reference to <I>cv2</I> <TT>T</TT>"
creates the type "reference to <I>cv12</I> <TT>S</TT>," where
<I>cv12</I> is the union of the cv-qualifiers <I>cv1</I> and
<I>cv2</I>.  Redundant cv-qualifiers are ignored.
[<I>Example:</I>
</P>

<PRE>
    template &lt;class T&gt; class X {
        f(const T&amp;);
        /* ... */
    };
    X&lt;int&amp;&gt; x;    // X&lt;int&amp;&gt;::f <I>has the parameter type</I> const int&amp;
</PRE>

&#8212;<I>end example</I>]

</BLOCKQUOTE>
</LI>

<LI>In 13.10.3 [<A href="https://wg21.link/temp.deduct#2.3">temp.deduct</A>] bullet 2.3 sub-bullet
5, remove the indicated text:

<BLOCKQUOTE>

Attempting to create <DEL>a reference to a reference type or</DEL> a
reference to <TT>void</TT>.

</BLOCKQUOTE>
</LI>
</OL>

<P>(See also paper J16/00-0022 = WG21 N1245.)</P>

<BR><BR>
</BODY>
</HTML>
