C++ Logo


Advanced search

Subject: Selecting the best viable function when a designated list initialization is used.
From: Vladimir Grigoriev (vlad.moscow_at_[hidden])
Date: 2021-05-25 05:06:32

In the section « 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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups