Date: Sun, 25 Feb 2024 14:16:40 +0000
On Sunday, February 25, 2024, Frederick Virchanza Gotham wrote:
>
> If you absolutely must create a variable of class type that might throw,
> then use std::optional:
>
> { _Bulldoze:
> optional<stringstream> ss;
> if ( ss ) *ss << 77;
> if ( ss ) cout << std::move(*ss).str();
> }
>
I forgot the 'emplace':
{ _Bulldoze:
optional<stringstream> ss;
ss.emplace();
if ( ss ) *ss << 77;
if ( ss ) cout << std::move(*ss).str();
}
>
> If you absolutely must create a variable of class type that might throw,
> then use std::optional:
>
> { _Bulldoze:
> optional<stringstream> ss;
> if ( ss ) *ss << 77;
> if ( ss ) cout << std::move(*ss).str();
> }
>
I forgot the 'emplace':
{ _Bulldoze:
optional<stringstream> ss;
ss.emplace();
if ( ss ) *ss << 77;
if ( ss ) cout << std::move(*ss).str();
}
Received on 2024-02-25 14:16:41