C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: List initialization
From: Edward Catmur (ecatmur_at_[hidden])
Date: 2021-06-10 07:37:34


On Thu, 10 Jun 2021 at 13:28, Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Also is it this rule valid for designated initializations?
>
> For example if we have
>
> struct A
> {
> int x, z;
> };
> struct B
> {
> int x, y, z;
> };
> void g( const A & )
> {
> std::cout << "void g( const A & )\n";
> }
> void g( const B & )
> {
> std::cout << "void g( const B & )\n";
> }
>
> then is this call
>
> g( { .x = 1, .z = 2 } );
>
> ambiguous or the function with the parameter const A & will be called?
>

A and B are not array types, so [over.ics.rank]/3.1.2 does not apply.

Indeed, all the compilers agree that the call is ambiguous.



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

Older Archives on Google Groups