Date: Tue, 06 Sep 2022 17:34:05 +0000
On Tuesday, September 6th, 2022 at 7:25 AM, Arthur O'Dwyer via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> This is just std::visit. Here's the "very simple" version using the Null Object pattern (i.e., creating a new dummy subclass of IRS232 to represent "no connection"):
> https://godbolt.org/z/rEW6aq744
> And here's the "less simple" version:
> https://godbolt.org/z/h1rjzxGKG
>
> There are other ways to do it too, but std::visit seems like the simplest — and it's already present in C++17.
>
The logic is true, while the point of
this proposal was probably to allow
variant to return a pointer to its
own buffer without breaking the
type system.
>
> This is just std::visit. Here's the "very simple" version using the Null Object pattern (i.e., creating a new dummy subclass of IRS232 to represent "no connection"):
> https://godbolt.org/z/rEW6aq744
> And here's the "less simple" version:
> https://godbolt.org/z/h1rjzxGKG
>
> There are other ways to do it too, but std::visit seems like the simplest — and it's already present in C++17.
>
The logic is true, while the point of
this proposal was probably to allow
variant to return a pointer to its
own buffer without breaking the
type system.
-- Zhihao Yuan, ID lichray The best way to predict the future is to invent it. _______________________________________________
Received on 2022-09-06 17:34:17