C++ Logo


Advanced search

Re: [std-proposals] Base class reflection

From: Billy Martin <bmartin_at_[hidden]>
Date: Tue, 31 Jan 2023 20:50:04 -0800
The search can be done with simple template programming, see my example.
There is no need to mess around with maps or typeids. Nor is there need to
modify the behavior of std::any. People could provide what polymorphic
support they want to their own type erasing classes as they see fit with

On Tue, Jan 31, 2023 at 4:54 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> At present, `any` cannot do this (and I would argue *should not*, but
> that's neither here nor there). To implement this conversion, you
> would have to store some kind of map from a typeid (or something
> similar) to a conversion function that converts a `D` to that
> particular type. This would be built by introspecting all of the base
> classes of `D` at the time of its creation and storing this map along
> with `D` inside the type-erased `any`.
> Is that an accurate description of what you're trying to achieve?

Received on 2023-02-01 04:50:17