CppCon 2021 has ended
Back To Schedule
Monday, October 25 • 4:45pm - 5:45pm
Implementing static_vector: How Hard Could it Be?

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
static_vector is a std::vector that allocates things on the stack instead of the heap. We have std::vector, so it should be easy to write a non-allocating version, right?

Sadly, it's not quite that simple. There are many aspects of the vector interface that make sense based on a container that can reallocate, but do not make sense for a container that cannot. This leads to some API differences. static_vector also faces certain challenges around constexpr that makes it both more and less constexpr than std::vector.

We will go into detail on how std::vector and how static_vector work, how they are similar, and how they differ. This presentation will be focusing on lower-level details and interactions with specific language features in C++20 and (hopefully) C++23. There will be lots of code examples, and we'll step through how they work and where they fall short, trying to build up to a working, production-ready solution.

avatar for David Stone

David Stone

Software Engineer, Quantlab
David Stone has worked on autonomous vehicles, large-scale distributed systems, and now works developing software for high-frequency trading. He is a member of the C++ Standardization Committee, where he chairs the Modules Study Group (SG2) and is the vice chair of the Evolution Working... Read More →

Monday October 25, 2021 4:45pm - 5:45pm MDT
B) Summit 8/9