Why std::vector Can't Save You (And What to Use Next)

Online Workshops + Training Sessions Available through April-June 2026 from only £150 ($200) 14 Sessions Available on a range of topics. Student Rates available from only £45/$60! US and EU friendly session times. https://cpponline.uk/ --- O(1) or O(no-no-no) - Mastering the unordered_map - Kevin Carpenter - C++Online 2026 In modern C++, std::vector is king. We reach for it as our default, cache-friendly, contiguous sequence. But what happens when your problem doesn't fit a simple array? What is the next container you should reach for? Lets dives into the data that proves std::unordered_map is the #2 container in modern C++. Its dominance signifies a fundamental shift in application design: the performance-critical need for O(1) average-case key-value lookups. Join as we move beyond "just use a hash map" and explore the critical, real-world implications of this choice. We'll start by benchmarking the classic std::map (red-black tree) against std::unordered_map (hash table) to understand exactly what you gain—and what you might lose. However this power comes with risks. An average-case O(1) can quickly degrade to a catastrophic O(n) without warning. We will profile and dissect the actual costs of using a hash map: The Hash: What makes a good hash function? We'll go beyond std::hash and see how to write effective, fast hasher. The Collision: How do different collision-handling strategies impact performance and memory? The Re-hash: What is ""load factor,"" and when does the hidden cost of a full table re-hash destroy your performance gains? We'll conclude with a practical decision-making framework for when to choose std::unordered_map, when to fall back on the ordered std::map, and how std::string—the container we often forget is a container—fits into this modern landscape. You will leave this session knowing precisely which data structure to deploy for maximum performance. Slides: https://github.com/kevinbcarpenter/o-... --- Work at Hudson River Trading (HRT): https://tinyurl.com/safxfctf --- Kevin Carpenter Kevin Carpenter is a Software Engineering Manager at EPX, where he oversees the architecture of real-time transaction processing systems. With 17+ years of deep C++ experience, Kevin has spent the last decade in the financial sector, moving from stochastic financial modeling to low-latency payment networks. He specializes in the ""art of modernization""—evolving established C++ architectures to interoperate seamlessly with new Go-based microservices and emerging payment technologies like Apple Tap to Pay. A passionate advocate for technical excellence, Kevin served as the Technical Editor for C++ Memory Management (Packt) and frequently speaks on tooling and best practices. He is also the Conference Director of SwiftCraft and a key volunteer leader for CppCon and C++ on Sea, working to connect developers across the globe. --- C++Online is the annual, online only conference for the entire C++ community. The conference is designed to provide a more accessible option for C++ developers who might find attending other international C++ conferences more difficult or financially restrictive, at a time of year where we traditionally see less in-person cpp conferences due to weather, holidays and other restrictions. The Online C++ Conference - https://cpponline.uk   / cpponline   https://x.com/cpponline https://www.facebook.com/profile.php?...   / cpponline   https://mastodon.social/@cpponline https://bsky.app/profile/cpponline.bs... --- Streamed & Edited by Digital Medium Ltd - online.digital-medium.co.uk --- C++Online - The Online C++ Conference organized by Shaved Yaks: https://shavedyaks.com/ & Digital Medium: https://events.digital-medium.co.uk --- #cpp #cplusplus #cpponline #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer