Topic: Core Issue 106: References to references


Author: Lisa Lippincott <lisa_lippincott@bigfix.com>
Date: 2000/06/07
Raw View
Core language issue 106 addresses the problems of references to
template parameters or typedef names which themselves name reference
types.  As I understand it, the intent of the proposed resolution
is to allow such reference types to be formed, and to treat them as
simple references.

I agree with that intent, but I don't think the proposed wording
adequately addresses cv-qualified references.  Here's the proposed
wording for template parameters:

   Add the following as paragraph 4 of 14.3.1=A0 temp.arg.type:=20

      If a template-argument for a template-parameter T names a
      reference type, then T& names that same reference type.
      [Example:=20
=20
          template <class T> class X {=20
              f(const T&);=20
              /* ... */=20
          };=20
          X<int&> x;    // X<int&>::f has the parameter type const int&=20

       =8Bend example]=20

In the example, "T&" would clearly refer to int&.  But since "const T&"
is parsed as "(const T)&", it does not follow that "const T&" refers
to const int&.

I suggest treating cv-qualified references directly:

     If a template-argument for a template-parameter T names a
     reference type S&, then cv T& names the reference type cv S&.

A similar change should be made to the wording for typedefs.

                                                --Lisa Lippincott

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: wmm@fastdial.net
Date: 2000/06/07
Raw View
In article <020620001409248792%lisa_lippincott@bigfix.com>,
  Lisa Lippincott <lisa_lippincott@bigfix.com> wrote:
> Core language issue 106 addresses the problems of references to
> template parameters or typedef names which themselves name reference
> types.  As I understand it, the intent of the proposed resolution
> is to allow such reference types to be formed, and to treat them as
> simple references.
>
> I agree with that intent, but I don't think the proposed wording
> adequately addresses cv-qualified references.  Here's the proposed
> wording for template parameters:
>
>    Add the following as paragraph 4 of 14.3.1=A0 temp.arg.type:=20
>
>       If a template-argument for a template-parameter T names a
>       reference type, then T& names that same reference type.
>       [Example:=20
> =20
>           template <class T> class X {=20
>               f(const T&);=20
>               /* ... */=20
>           };=20
>           X<int&> x;    // X<int&>::f has the parameter type const
int&=20
>
>        =8Bend example]=20
>
> In the example, "T&" would clearly refer to int&.  But since "const
T&"
> is parsed as "(const T)&", it does not follow that "const T&" refers
> to const int&.
>
> I suggest treating cv-qualified references directly:
>
>      If a template-argument for a template-parameter T names a
>      reference type S&, then cv T& names the reference type cv S&.
>
> A similar change should be made to the wording for typedefs.

Yes, this looks like a problem.  I'll make a note of it in the
issues list and we'll work on it some more at the next meeting.

Thanks for pointing it out.
--
William M. Miller, wmm@fastdial.net
OnDisplay, Inc. (www.ondisplay.com)


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]