Date: Sat, 4 Apr 2026 11:56:14 +0100
On Sat, 4 Apr 2026, 11:19 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
>
I only read the abstract, but how does changing the optional class template
from one template parameter to two template parameters provide complete
backwards compatibility? It means optional<X> has a different mangled name,
and so it's an ABI break.
> 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
>
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
>
I only read the abstract, but how does changing the optional class template
from one template parameter to two template parameters provide complete
backwards compatibility? It means optional<X> has a different mangled name,
and so it's an ABI break.
> 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:56:34
