iboB / dynamix

:fish_cake: A new take on polymorphism
MIT License
667 stars 45 forks source link

Allow methods from base classes to implement messages without `using` #20

Closed iboB closed 6 years ago

iboB commented 6 years ago

The problem is basically this:

class a {
public:
    void foo(); 
};

class b : public a {};

decltype(&b::foo); // -> void (a::*)()

The caller in the message macros gets instantiated with as <Mixin, Ret, Ret (PARENT::&Method)(args)> and cannot be implicitly cast to <Mixin, Ret, Ret (Mixin::&Method)(args)> .

An explicit cast needs to be added in get_caller_for

iboB commented 6 years ago

The workaround for now is to add using a::foo; in b's public section, so that &b::foo has the correct type

iboB commented 6 years ago

This was fixed in 1.3.1 along with the constness overload fix

iboB commented 6 years ago

This cannot be properly fixed for clang until https://bugs.llvm.org/show_bug.cgi?id=35971 is fixed

iboB commented 6 years ago

After the discussion in the bug report it seems that it's a standard issue. There is simply no way to fix this by casting before c++17.

To make a proper implementation a metafunction needs to extract the appropriate parent from the method name, instantiate msg_caller::caller appropriately (by adding a Parent type as a template argument) and performing the cast inside.

Will work on this next

iboB commented 6 years ago

Closing as there is a workaround and this cannot be fixed with c++11. Comments are added to fix properly when we switch to c++17.