Загрузка...

Constexpr STL Containers: Why C++20 Still Falls Short - Sergey Dobychin - CppCon 2025

https://cppcon.org​
---

Constexpr STL Containers: Why C++20 Still Falls Short - Sergey Dobychin - CppCon 2025
---

One of the most powerful features that sets C++ apart from many other languages is its ability to perform complex constant evaluation at compile time using constexpr. With each new language standard, these capabilities have expanded — and C++20 took a big step forward by allowing dynamic memory allocation in constexpr functions via operator new. This made it possible, for example, to use containers like std::vector and std::string in constexpr code.

However, there’s still a key limitation: you can only use these containers in constexpr functions — not as top-level constexpr objects. That means you can't declare a constexpr std::vector or std::string at global scope and use it later in runtime without overhead for initialization. The language still doesn’t fully support top-level dynamic containers in constant expressions.

In this talk, I’ll explore the current state of constant evaluation in modern C++, with a special focus on dynamic memory allocation in constexpr contexts. I’ll walk through the limitations in C++20 and show how you can go beyond them by implementing a custom allocator that enables truly compile-time std::vector, std::string, and other STL containers, which will become fully supported as constexpr in future standards, thus opening the door to more powerful and flexible compile-time programming.
---

Slides: https://github.com/CppCon/CppCon2025/blob/main/Presentations/constexpr_STL_Containers.pdf

Work at Hudson River Trading (HRT): https://tinyurl.com/safxfctf
---

Sergey Dobychin

Sergey worked in systems programming at Kaspersky Lab. Currently, he is developing desktop applications in C++.
---

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. You will enjoy inspirational talks and a friendly atmosphere designed to help attendees learn from each other, meet interesting people, and generally have a stimulating experience. Taking place this year in Aurora, Colorado, near the Denver airport, and including multiple diverse tracks, the conference will appeal to anyone from C++ novices to experts.
Annual CppCon Conference - https://www.cppcon.org
https://www.linkedin.com/company/cppcon
https://x.com/cppcon
https://www.facebook.com/CppConference
https://www.reddit.com/r/cppcon/
https://mastodon.social/@CppCon
---

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
YouTube Channel Managed by Digital Medium Ltd: https://events.digital-medium.co.uk
---

#cpp #cplusplus #cppcon #cppprogramming #cplusplusprogramming #softwaredevelopment #softwareengineering #coding #code #computerscience #technology #technews #programming #programmer

Видео Constexpr STL Containers: Why C++20 Still Falls Short - Sergey Dobychin - CppCon 2025 канала CppCon
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять