#Help needed trying to figure out if derived class overrides an overloaded virtual method.

15 messages · Page 1 of 1 (latest)

frail root
#

Hey, I'm working on an event-based plugin system for my application and I'd need to know if certain event handlers are overridden so I can determine whether they need to be called or not.

So here's an simplified version of my problem https://godbolt.org/z/WEWd7Gd9v and I'm kind of stuck to be honest. If anyone could help it would be greatly appreciated 😄

teal parrotBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

frail root
#

oh shit I did an oopsie when simplifying my problem

#

bool overridesEvent(PluginBase* pPlugin) {

is supposed to be

bool overridesEvent(auto* pPlugin) {

#

Then it should be using PluginDerived = typename std::remove_pointer_t<decltype(pPlugin)>;

#

I had remove_reference_t because I was passing a reference to a pointer at some point

#

There still might be other small quirks like that but honestly I'm not thinking straight rn, it's 2am for me

drowsy zenith
#

do it tommororw.

frail root
#

I ended up doing this monstrosity https://godbolt.org/z/sdzGPoa6h

#

I figure out the index where the virtual function is located in the vtable, then I compare the function address from that vtable from the real instance with a base one

#

I'm not so confident it should work on all compilers, but at this point I don't really care and just want it to compile and work using Clang

#

Well unless if someone has a better idea

#

!solved for now

teal parrotBOT
frail root
#

!solved