C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 5 Jul 2023 10:50:27 +0100
On Wed, Jul 5, 2023 at 10:45 AM Frederick Virchanza Gotham
<cauldwell.thomas_at_[hidden]> wrote:
>
> or maybe even have an operator '(class<obj>)' that you would use as follows:
>
> std::optional_direct< std::stringstream > obj;
> (class<obj>).emplace();
>
> if ( (class<obj>).optional_directhas_value() ) DoSomething();


That last line should be:

    if ( (class<obj>).has_value() ) DoSomething();

Received on 2023-07-05 09:50:40