Skip to content

Inheritance support #9

@BartolomeyKant

Description

@BartolomeyKant

Hi!
Looking at code I can't understand. Is it possible to initialize Rc<Base> with Rc<Derived> assuming std::is_base_of_v<Base, Derived> == true?

I know it's impossible now because of lack templated copy constructor and assignment operator. But How could I implement that?

The main problem for me here is how to convert Rc<Derived>::Data* into Rc<Base>::Data*.

I've made a short example to illustrate the problem https://godbolt.org/z/TTKj1jPcW
Here I create a class Derived derived from Base1 and Base2 and try cast stored pointer into one of them. In the output you may see what result is the same for different functions call. This means vtable pointer is not converted properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions