C++ Logo

std-proposals

Advanced search

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

From: Guy Davidson <standard.guy_at_[hidden]>
Date: Sat, 4 Apr 2026 11:50:00 +0100
There is a brief document covering this at

 

https://www.iso.org/files/live/sites/isoorg/files/developing_standards/who_develops_standards/docs/use%20of%20AI.pdf

 

Cheers,

G

 

From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Andre Kostur via Std-Proposals
Sent: 04 April 2026 11:39
To: std-proposals_at_[hidden]
Cc: Andre Kostur <andre_at_[hidden]>
Subject: Re: [std-proposals] zero overhead for std::optional

 

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] <mailto: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] <mailto:Std-Proposals_at_[hidden]> 
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-04-04 10:50:09