On Thu, Apr 11, 2024 at 9:32 AM Mihail Mihaylov via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
On Thu, Apr 11, 2024 at 4:14 PM Gašper Ažman <gasper.azman@gmail.com> wrote:
dynamic_cast structures are only included for types with a vtable.

And a compile-time list of base types is included for... no types at all. Whatever the actual implementation, it will require something which isn't currently available.

All I'm saying is that asking for `any` to support taking out an instance of a base class instead of the actual class stored in it is not unreasonable.

If you want to make a type-erased `my::Any` where one of the type-erased affordances is "any_cast to base," that's totally possible.
I show exactly how to do it in my "Back to Basics: Type Erasure" from 2019.
Basically, any operation you can think of can be turned into an affordance and type-erased, as long as you're willing to write your own type-erased type. (Which is easy and everyone should know how to do it. :) See "Type-erased UniquePrintable and PrintableRef" from November 2020.)

–Arthur