With PR121068 partially addressed by r16-2432-gfdbc5ff61b4710, placement new can now be used to initialize the internal array of std::inplace_vector.
libstdc++-v3/ChangeLog: * include/std/inplace_vector (inplace_vector::_M_init): Use placement new to create array. --- This does not remove the is_trivial (trivally default, copy, move cosntructible and destructible requirements) as we will need partially constructed array in unions for that. OK for trunk? libstdc++-v3/include/std/inplace_vector | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/inplace_vector b/libstdc++-v3/include/std/inplace_vector index 290cf6eb0e9..c6c28096a7d 100644 --- a/libstdc++-v3/include/std/inplace_vector +++ b/libstdc++-v3/include/std/inplace_vector @@ -877,12 +877,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - // TODO: use new(_M_elems) _Tp[_Nm]() once PR121068 is fixed if constexpr (is_trivial_v<_Tp>) - for (size_t __i = 0; __i < _Nm; ++__i) - _M_elems[__i] = _Tp(); + new (static_cast<void*>(_M_elems)) _Tp[_Nm](); else - __builtin_unreachable(); // only trivial types are supported at compile time + // only trivial types are supported at compile time + __builtin_unreachable(); } } -- 2.49.0