C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::get_if for std::any

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 12 Apr 2025 20:51:17 +0300
On Sat, 12 Apr 2025 at 20:31, Henning Meyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Is there a reason, why there isn't or shouldn't be
> std::get_if<T>(std::any*)?
>
> I believe both are based on boost designs, and boost::variant did not
> have a get_if.
>
> I would like to work generically with std::variant and std::any.

So, write a simple utility to do that: https://godbolt.org/z/exM897Gjd

As far as adding a std::get_if that can take an any* goes, fine by me,
I wouldn't be opposed to it, it seems reasonable. Considering the
simplicity
of just doing it yourself, I don't see myself writing a proposal for that.

Received on 2025-04-12 17:51:32