Title
Creating references to references during template deduction/instantiation
Status
cd1
Section
unknown [unknown]
Submitter
Bjarne Stroustrup

Created on 1999-09-14.00:00:00 last changed 161 months ago

Messages

Date: 2001-10-15.00:00:00

[Moved to DR at 10/01 meeting.]

Date: 2001-04-15.00:00:00

Proposed resolution (04/01):

  1. Add the following as paragraph 6 of 9.2.4 [dcl.typedef]:

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

        int i;
        typedef int& RI;
        RI& r = i;          // r has the type int&
        const RI& r = i;    // r has the type const int&
    
    end example]
  2. Add the following as paragraph 4 of 13.4.2 [temp.arg.type]:

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

        template <class T> class X {
            f(const T&);
            /* ... */
        };
        X<int&> x;    // X<int&>::f has the parameter type const int&
    
    end example]
  3. In 13.10.3 [temp.deduct] paragraph 2 bullet 3 sub-bullet 5, remove the indicated text:
    Attempting to create a reference to a reference type or a reference to void.

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

Date: 2000-09-16.00:00:00

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

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg699
2001-11-09 00:00:00adminsetstatus: ready -> dr
2000-11-18 00:00:00adminsetstatus: review -> ready
2000-09-16 00:00:00adminsetmessages: + msg377
2000-09-16 00:00:00adminsetstatus: ready -> review
2000-05-21 00:00:00adminsetstatus: drafting -> ready
2000-02-23 00:00:00adminsetstatus: open -> drafting
1999-09-14 00:00:00admincreate