Date: Mon, 26 Jan 2026 07:46:51 -0800
On Monday, 26 January 2026 02:54:52 Pacific Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> I'm curious though . . . if polymorphic objects are very seldom (or
> never) kept in containers, then why was there so much talk about
> trivial location for polymorphic types (i.e. the need for
> 'restart_lifetime' to re-sign the vptr)?
Because the problem wasn't vectors. It was std::any and QVariant, which type-
erase the copying in the first place. A trivially copyable type must be
memcpyable, as I'm sure you'll agree. Note it's a sufficient condition, not a
necessary one.
Re-signing the vptr isn't a memcpy. Therefore, that type shouldn't be marked
trivially copyable.
Gotham via Std-Proposals wrote:
> I'm curious though . . . if polymorphic objects are very seldom (or
> never) kept in containers, then why was there so much talk about
> trivial location for polymorphic types (i.e. the need for
> 'restart_lifetime' to re-sign the vptr)?
Because the problem wasn't vectors. It was std::any and QVariant, which type-
erase the copying in the first place. A trivially copyable type must be
memcpyable, as I'm sure you'll agree. Note it's a sufficient condition, not a
necessary one.
Re-signing the vptr isn't a memcpy. Therefore, that type shouldn't be marked
trivially copyable.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-01-26 15:47:04
