C++ Logo

std-discussion

Advanced search

Re: Selecting the best viable function when a designated list initialization is used.

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Tue, 25 May 2021 15:07:50 +0100
Hi,

My optimistic guess is to leave room to enable unordered designated initializers in the future (at least in limited cases), without changing overload resolution.

Cheers,
Lénárd


-------- Original Message --------
From: Vladimir Grigoriev via Std-Discussion <std-discussion_at_[hidden]>
Sent: May 25, 2021 11:06:32 AM GMT+01:00
To: std-discussion <std-discussion_at_[hidden]>
Cc: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Subject: [std-discussion] Selecting the best viable function when a designated list initialization is used.


In the section «12.4.3.1.5 List-initialization sequence» in the second paragraph there is an example
 
struct A { int x, y; };
struct B { int y, x; };
 
void g(A a);
void g(B b);
 
g({.x = 1, .y = 2});
 
And in a comments to this example there is written that the call of the function g is ambiguous.
 
On the other hand, in the paragraph there is also written that
«If, after overload resolution, the order does not match for the selected overload, the initialization of the parameter will be ill-formed»
 
So my question is why is in the C++ Standard adopted that the call is ambiguous instead of making the function void g( A a ) the most viable function because the call of the function void g( B b ) is ill formed?
 
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-05-25 09:08:04