Array reference vs array decay in overload resolution
tentatively ready
Section [over.ics.rank]
Faisal Vali

Created on 2013-10-01.00:00:00 last changed 2 weeks ago


Date: 2021-06-15.00:00:00

Proposed resolution (June, 2021):

Add the following as a new bullet following [over.ics.rank] bullet 3.2.6:

Two implicit conversion sequences of the same form are indistinguishable conversion sequences unless one of the following rules applies:

  • List-initialization sequence L1 is a better conversion sequence...

  • Standard conversion sequence S1 is a better conversion sequence than standard conversion sequence S2 if

    • ...

    • S1 and S2 include reference bindings (9.4.4 [dcl.init.ref]), and the types to which the references refer are the same type except for top-level cv-qualifiers, and the type to which the reference initialized by S2 refers is more cv-qualified than the type to which the reference initialized by S1 refers. [Example 6:...

    • S1 is a reference binding to an array and S2 is an array-to-pointer conversion (7.3.3 [conv.array]). [Example 7:

        template<class T, unsigned N> void f(T (&)[N]); // #1
        template<class T> void f(T *t);                 // #2
        int r[3]{1, 2, 3};
        void g() {
          f(r);    // OK: calls #1

      end example]

Date: 2013-10-01.00:00:00

The current rules make an example like

  template<class T, size_t N> void foo(T (&)[N]);
  template<class T> void foo(T *t);

  int arr[3]{1, 2, 3};

ambiguous, even though the first is an identity match and the second requires an lvalue transformation. Is this desirable?

Date User Action Args
2022-11-20 07:54:16adminsetstatus: review -> tentatively ready
2021-11-15 00:00:00adminsetmessages: + msg6531
2021-11-15 00:00:00adminsetstatus: drafting -> review
2014-03-03 00:00:00adminsetstatus: open -> drafting
2013-10-01 00:00:00admincreate