C++ Logo

std-discussion

Advanced search

List initialization

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Thu, 10 Jun 2021 14:17:58 +0300
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?  
 
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
void f(double (&&)[] ); // #2
void f(int (&&)[2]); // #3
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?
 
With best regards,
Vlad from Moscow
 
 
 
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2021-06-10 06:18:04