4 ms·
You can implement it with templates and people do things like this often. In modern C++, it's even pretty easy to make this type of trick support `constexpr`.
by Conscat 2mo ago
You can implement it with templates and people do things like this often. In modern C++, it's even pretty easy to make this type of trick support `constexpr`.
- p_l 2mo agoDo it manually and hacky, yes. At that point though, one could claim that they can do it in C as well and implement half of Objective-C
- pjmlp 2mo agoExcept that to keep objc_msgSend performance good enough with Objective-C dispatch semantics, a little bit of pure Assembly code help is required.
- p_l 2mo agowell, I wasn't implying full semantics. Or fast, to be honest. Still could be faster than vtable though...
- pjmlp 2mo agoSure enough. Going back to the technical implementation part, depending on the C++ version, and being able to understand the target at compile time, no need to do it manually and hacky. There is enough support in constexpr, consteval, concepts, and now compile time reflection, to do it automatically, assuming the dispatch target can be resolved at compile time.