New (and Old) Standard Library Containers: How to Choose the Right Container in C++26 and Beyond

Alan Talbot

⏱ 90 minute session
beginner
intermediate
advanced
09:30-11:00, Friday, 4th April 2025
Choosing the right container and using it correctly can have a profound impact on the performance of a program. The many containers in the C++ Standard Library exist largely because they provide different performance profiles. Choosing between them requires an understanding of the speed and size tradeoffs of each container and the difference between algorithmic complexity and actual behavior. Unfortunately, partly for historical reasons, the APIs of the Standard Library containers can be misleading in this regard. They are also a moving target: C++26 will provide two new containers (the first since C++11), and C++23 provided four new container adaptors. Improvements to containers appear in every new version of C++, and there are at least two container proposals in the early stages, targeted at C++29 or beyond.

In this talk we will look at the new containers and adaptors in the context of the existing library. We will analyze all the containers to determine the abstractions they are meant to express and the practical limitations they impose, with an eye to understanding how to select the best solution for the problem at hand. We will then look at the proposals for future containers, discuss the proposed designs, and consider whether they would add sufficient value to justify the considerable Committee time necessary to make them part of the Standard Library.

🏷 C++26
🏷 Standard Library
🏷 containers
🏷 performance

Alan Talbot

Alan Talbot started programming in BASIC on a DEC PDP-8. He began his professional programming career as a pioneer in music notation software while in college and continued to be a leader in that industry for two decades. More recently he has worked with digital maps and railroad simulation. He has been using C++ since 1990 and has been a member of the ISO C++ committee (WG21) since 2005. Most of his C++ contributions have focused on improvements in efficiency, including container emplacement behavior, extraction and merging of associative container nodes, and improvements to unions.