C++ Logo

std-proposals

Advanced search

Re: [std-proposals] zero overhead for std::optional

From: Andre Kostur <andre_at_[hidden]>
Date: Sat, 4 Apr 2026 10:38:54 +0000
Doesn’t the ISO prohibit AI generated text in proposals?

On Sat, Apr 4, 2026 at 10:19 AM Peter Neiss via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hello,
>
> the std::optional as it is today has an overhead flaw with the additional
> bool in the implementation to check if a value is there. In a lot of major
> and important cases this is suboptimal. (It is necessary for the general
> case).
>
> Principal example are pointers which have a NULL that is traditionally
> used to mark them as "not value".
>
> I vibed (used KI claude) to generate a proposal to fix this in C++ 29.
>
> Please have a look here and the attached proposal.pdf.
>
> https://github.com/PeterNeiss/optional
>
> TL;DR
> sizeof(std::optional<int*>) == 2*sizeof(int*) // 64bit platform: 16Byte
> sizeof(std::optional<int*, nullptr>) == 2*sizeof(int*) // 64bit platform:
> 8Byte
>
> Yours,
> Peter
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2026-04-04 10:39:08