C++ Logo

std-proposals

Advanced search

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

From: Henning Meyer <hmeyer.eu_at_[hidden]>
Date: Sat, 12 Apr 2025 19:31:38 +0200
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.

Ideally, type-erased types had a standard interface like containers, so
I can switch between
std::variant, boost::variant, eastl::any, etc in the same way I can
switch out std::unordered_map for the many available hash map
implementations.

I don't think the standard library provides strong guidance here for
interfaces that other implementations of the same concepts can adopt.

Received on 2025-04-12 17:31:41