Discover more from Daily bit(e) of C++
Daily bit(e) of C++ | Type erasure: void*
Daily bit(e) of C++ #319, Type erasure imitating dynamic dispatch using void* and function pointers.
One downside of relying on dynamic dispatch is the intrusive instrumentation overhead.
Types with virtual methods store a pointer to the virtual function table and are disqualified from many optimizations and conveniences (trivial copyability, aggregate initialization).
Fortunately, the same logic can be manually re-implemented externally using void* and function pointers.
Thanks for reading Daily bit(e) of C++! Subscribe for free to receive new posts and support my work.