C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 25 Jun 2023 14:42:02 +0100
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() )


> 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.

Received on 2023-06-25 13:42:12