https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121

--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to [email protected] from comment #15)
> But the container is there already, so I'm confused ...

No it isn't. It's in a union, and we do not make the union member active,
because if we did that it would construct a whole array *and* all its
subobjects. We don't want to construct N subobjects, we want it to start empty,
and then populate the subobjects one-by-one.

What inplace_vector does is use a union to reserve storage for an array without
creating that array. It's a union with no active member. That works fine when
we do it for a single object like in std::optional<T>, but here we want to do
it for T[N]. Currently the C++ standard makes this very difficult (because
usually when you define an array, of course you want its subobjects to be
defined as well).

Reply via email to