Date: Fri, 20 Jan 2023 13:21:38 -0600
That is what i get for trying to type code in an email client instead of a proper IDE and compile/run.
A should have been I. That is it is legal (though not common) to have an array of pointers to some base object.
An array of base should not be initializable to derived objects though as you only have storage space for the base (including the v-table). I suppose if the derived object has no data members it might be the possible to make this work, but I'm pretty sure we already don't allow that because base and derived should have separate pointer values - but the exact reason escapes me.
On Fri, Jan 20, 2023, at 08:00, Julien Allali via Std-Proposals wrote:
> not sure to understand: what does A stands for?
>
> thx
>
> Julien
>
> On 20/01/2023 13:37, Henry Miller via Std-Proposals wrote:
>> Opps, I meant A a[] = {&b1, &b2, &b3, &b4, &b5};
>>
>> Obviously if a is uninitialized it is undefined behavior
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
A should have been I. That is it is legal (though not common) to have an array of pointers to some base object.
An array of base should not be initializable to derived objects though as you only have storage space for the base (including the v-table). I suppose if the derived object has no data members it might be the possible to make this work, but I'm pretty sure we already don't allow that because base and derived should have separate pointer values - but the exact reason escapes me.
On Fri, Jan 20, 2023, at 08:00, Julien Allali via Std-Proposals wrote:
> not sure to understand: what does A stands for?
>
> thx
>
> Julien
>
> On 20/01/2023 13:37, Henry Miller via Std-Proposals wrote:
>> Opps, I meant A a[] = {&b1, &b2, &b3, &b4, &b5};
>>
>> Obviously if a is uninitialized it is undefined behavior
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2023-01-20 19:22:01