C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: Extension to runtime polymorphism proposed

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 09 Apr 2026 17:10:11 -0700
On Thursday, 9 April 2026 12:58:56 Pacific Daylight Time Sebastian Wittmeier
via Std-Proposals wrote:
> std::tuple is one element after the other, with some padding for correct
> alignment. (in some standard libraries in reverse order of elements)

A smarter implementation would sort them in decreasing order of alignment
requirements so as to avoid intra-object padding and thus decrease the the
total object size.

Whether that is doable without undue compilation time is unknown. It was most
likely not doable with compilers of 2010 when std::tuple was first introduced
into the libraries. libc++, because it came late to the party, has a few
techniques that hadn't occurred to the developers of older implementations,
which now can't be fixed due to ABI.

However, the point is that this is an *implementation detail*. The language
does not impose the order, or the ABI for that matter.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-10 00:10:25