On Sun, Jun 25, 2023, 14:42 Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
On Sun, Jun 25, 2023 at 1:34 PM Edward Catmur wrote:
> So you're checking on every access? That sounds like it's hiding a potentially expensive operation.

After you've played around with the Debug build for a while and are
satisfied that the object is never accessed before it's constructed,
then in the Release build it could become:

#define g_obj ( g_optional_obj.value() )

How? Who controls this setting? 

> If we were to have a feature like that, it feels like it would be worth generalising
> it to expression variables and, ultimately, call by name.

I don't understand what you're saying here. Please elaborate.

You have, essentially, a variable that evaluates an expression on every access. If you allow evaluating an arbitrary expression you have expression variables, or, as function parameters, call by name.