Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call methods in derived class #20

Open
uselessgoddess opened this issue Jul 16, 2021 · 3 comments
Open

Call methods in derived class #20

uselessgoddess opened this issue Jul 16, 2021 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@uselessgoddess
Copy link
Member

Use static_cast to resolve this problem

Delegate(std::shared_ptr<Class> object, ReturnType(Class:: *member)(Args...))
: Delegate(std::make_shared<MemberMethod<Class>>(std::move(object), member)) { }

struct base
{
    void foo() { std::cout << "foo"; }
};

struct derived : public base {};

auto object = std::make_shared<derived>();
auto delegate = Platform::Delegates::Delegate((std::shared_ptr<base>)object, &derived::foo);
delegate();
@uselessgoddess uselessgoddess added bug Something isn't working good first issue Good for newcomers labels Jul 16, 2021
@Konard
Copy link
Member

Konard commented Jul 22, 2021

Which problem?

@uselessgoddess
Copy link
Member Author

uselessgoddess commented Jul 22, 2021

auto object = std::make_shared<derived>();
auto delegate = Delegate((std::shared_ptr<base>)object, &derived::foo); // work
auto delegate = Delegate(object, &derived::foo); // does not work 

@uselessgoddess
Copy link
Member Author

Please fix it. I cannot work with this project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants