- Here is a personal programming-related blog.
- Want to know about me?
- To contact me, use one of the methods below.
Virtual Function Costs
Measuring real performance cost of C++ virtual functions: vtable lookup overhead, branch misprediction, devirtualization, and when to avoid virtual dispatch.
C++ Type Dispatch
Techniques for type dispatch in C++: tag dispatch, if constexpr, std::variant with std::visit, and how to choose the right approach for your use case.
How to Resolve Macro Name Collisions
Practical techniques to resolve C/C++ macro name collisions between system headers and user code: undef, parenthesization, and inline function workarounds.
C++: How to Access Private Members VALIDLY
A surprisingly valid C++ technique to access private class members using explicit template instantiation, with analysis of what the standard actually permits.
C++: Elegant Ways to Map Runtime Values to Types
How to elegantly dispatch from runtime values to compile-time types in C++ using techniques like std::variant, type lists, and template metaprogramming.
Algorithms behind Popcount
Three classical popcount algorithms: from naive bit-twiddling to the Hamming weight trick, plus how modern CPUs accelerate it with POPCNT and AVX-512.
C++ Virtual Table Tables(VTT)
A detailed walkthrough of how C++ virtual table of tables (VTT) works for classes with virtual base classes, with concrete memory layout examples.
What does C++ Object Layout Look Like?
Visual walkthrough of C++ object memory layout: member ordering, padding, base class subobjects, vtable pointers, and how multiple inheritance affects layout.
A Subtle Bug Before C++17
A deep dive into a subtle C++ performance bug: why over-aligned dynamic memory allocation was undefined before C++17 and how alignas interacts with operator new.
Iyengar111 NanoLog Source Code Reading
Deep dive into NanoLog, an extremely fast C++ logging library: how it achieves nanosecond-scale latency with lock-free queues and cache-line alignment.