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

2023-01-15


322. Deduction of reference conversions

Section: 13.10.3.4  [temp.deduct.conv]     Status: CD1     Submitter: Jason Merrill     Date: 14 Nov 2001

[Voted into WP at April 2003 meeting.]

Consider:

  struct S {
    template <class T> operator T& ();
  };

  int main ()
  {
    S s;
    int i = static_cast<int&> (s);
  }
13.10.3.4 [temp.deduct.conv] says that we strip the reference from int&, but doesn't say anything about T&. As a result, P (T&) and A (int) have incompatible forms and deduction fails.

Proposed Resolution (4/02):

Change the last chunk of 13.10.3.4 [temp.deduct.conv] paragraph 2 from

If A is a cv-qualified type, the top level cv-qualifiers of A's type are ignored for type deduction. If A is a reference type, the type referred to by A is used for type deduction.
to
If A is a cv-qualified type, the top level cv-qualifiers of A's type are ignored for type deduction. If A is a reference type, the type referred to by A is used for type deduction. If P is a reference type, the type referred to by P is used for type deduction.