Date: Sun, 19 Apr 2026 08:24:54 -0700
On Saturday, 18 April 2026 23:14:27 Pacific Daylight Time Simon Schröder wrote:
> Well, a variant has to store the reference/pointer plus the selected type.
> Sebastian suggested to just store the pointers/offsets. One of these uses
> less memory. Both probably have the same number of instructions for
> copying/creating the returned variant for operator[].
A variant cannot get around the fact that it needs to store the type ID
somehow, because asking about it is part of the API. If you try to visit it,
it must know which of the overloads of operator() to call.
> Well, a variant has to store the reference/pointer plus the selected type.
> Sebastian suggested to just store the pointers/offsets. One of these uses
> less memory. Both probably have the same number of instructions for
> copying/creating the returned variant for operator[].
A variant cannot get around the fact that it needs to store the type ID
somehow, because asking about it is part of the API. If you try to visit it,
it must know which of the overloads of operator() to call.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-04-19 15:25:06
