From Jason Turner
Watch on YouTube

Summary

Jason Turner investigates why a simple custom pair implementation outperforms std::pair in benchmarks by up to 310x in some compiler configurations. Through methodical experimentation with different compilers, optimization levels, and implementation variations, he discovers that the performance difference stems from how Clang handles template constructor forwarding. The episode demonstrates that std::pair's template forwarding constructor prevents certain compiler optimizations that are possible with a simpler, direct member initialization approach.

Resources

Tags