C++ Logo

std-proposals

Advanced search

Re: [std-proposals] In re: Issue2157

From: Brian Bi <bbi5291_at_[hidden]>
Date: Tue, 5 Dec 2023 16:30:09 -0500
On Tue, Dec 5, 2023 at 4:03 PM Ryan Nicholl via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I want to raise my personal concern around the proposed solution
> to Issue2157.
>
> I do not believe that std::array<T, 0> {{}}; should be required to be
> valid syntax. This prevents std::array<T, 0> from being implemented as an
> empty struct. It is also just logically inconsistent with an array that
> contains no elements. I believe this eliminates empty base class
> optimization and presents several other issues that I believe diverge from
> the 0 overhead principle. For this reason I think the solution ought to be
> reconsidered.
>

Since `std::array<int, 3> {{1, 2, 3}}` is valid, it is actually consistent
for `std::array<T, 0> {{}}` to be valid too.

Also, if the single element of `std::array<T, 0>` is an empty base class or
a data member declared with `[[no_unique_address]]`, then `std::array<T,
0>` can itself be an empty base class.


> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
*Brian Bi*

Received on 2023-12-05 21:30:22