C++ Logo

std-discussion

Advanced search

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

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Tue, 25 May 2021 13:06:32 +0300
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 05:06:38