C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: Use optional<T> as though it were T

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Sun, 25 Jun 2023 14:56:30 +0100
On Sun, Jun 25, 2023, 14:42 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> 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.

-- 
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-06-25 13:56:44