C++ Logo


Advanced search

Re: [std-proposals] Base class reflection

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Tue, 31 Jan 2023 15:27:36 -0500
On Tue, Jan 31, 2023 at 3:23 PM Billy Martin via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> You can't do this because there isn't any code that knows both B and D at
> compile time.
> The case I'm thinking of involves some templated container that has an
> object of type D. (Maybe it's a type erasure system, a smart pointer,
> whatever). That container knows the type D because it was passed as a
> template argument when it was instantiated with a brand new D object.
> Somewhere else, some other code has a pointer B* and they want it to point
> to this object, but they don't know what type D is (it might not even be
> knowable until runtime).

Can you please show some example code? Just write the exact code you think
you want to write, but pretend that `std::bases_of<T>::type` already
exists. Show how you'll solve your problem using `std::bases_of<T>::type`.


Received on 2023-01-31 20:27:50