Date: Thu, 10 Jun 2021 13:36:52 +0200

On Thu, Jun 10, 2021 at 02:17:58PM +0300, Vladimir Grigoriev via Std-Discussion wrote:

>

> In the paragraph # 3 of the section 12.4.3.2 Ranking implicit conversion sequences of the C++ 20 Standard there is written

>

> (3.1) — List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if

>

> and

>

> (3.1.2) — L1 and L2 convert to arrays of the same element type, and either the number of elements n1 initialized by L1 is less than the number of elements n2 initialized by L2, or n1 = n2 and L2 converts to an array of unknown bound and L1 does not,

>

> This description is entirely unclear. For starters what is «the number of initialized elements»? Is it the size of the initialized array or is it the number of initializers in the initializer ;list?

>

> Secondly, how can be n1 == n2 if the initialized arrays of unknown bounds?

you start with an array of known bounds (number of initializers) that

then gets converted to an array of unknown bounds, e.g.

void f(int (&&)[] );

void f(int (&&)[1]); // gets called

f( {1} );

> Thirdly, from the first statement (3.1) it follows that L1 is better than L2 when «L2 converts to an array of unknown bound and L1 does not» However in this example in the C++ Standard

>

> void f(int (&&)[] ); // #1

n1 = 1

> void f(double (&&)[] ); // #2

> void f(int (&&)[2]); // #3

n2 = 2

> f( {1} ); // Calls #1: Better than #2 due to conversion, better than #3 due to bounds

>

> the function #1 is selected instead of the function #3. Is it a typo?

n1 < n2 ==> #1 is selected

Christof

>

> In the paragraph # 3 of the section 12.4.3.2 Ranking implicit conversion sequences of the C++ 20 Standard there is written

>

> (3.1) — List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if

>

> and

>

> (3.1.2) — L1 and L2 convert to arrays of the same element type, and either the number of elements n1 initialized by L1 is less than the number of elements n2 initialized by L2, or n1 = n2 and L2 converts to an array of unknown bound and L1 does not,

>

> This description is entirely unclear. For starters what is «the number of initialized elements»? Is it the size of the initialized array or is it the number of initializers in the initializer ;list?

>

> Secondly, how can be n1 == n2 if the initialized arrays of unknown bounds?

you start with an array of known bounds (number of initializers) that

then gets converted to an array of unknown bounds, e.g.

void f(int (&&)[] );

void f(int (&&)[1]); // gets called

f( {1} );

> Thirdly, from the first statement (3.1) it follows that L1 is better than L2 when «L2 converts to an array of unknown bound and L1 does not» However in this example in the C++ Standard

>

> void f(int (&&)[] ); // #1

n1 = 1

> void f(double (&&)[] ); // #2

> void f(int (&&)[2]); // #3

n2 = 2

> f( {1} ); // Calls #1: Better than #2 due to conversion, better than #3 due to bounds

>

> the function #1 is selected instead of the function #3. Is it a typo?

n1 < n2 ==> #1 is selected

Christof

-- http://cmeerw.org sip:cmeerw at cmeerw.org mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

Received on 2021-06-10 06:36:58