GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

Mark <queue>, <deque> constexpr

C++26 support for deque and queue containers is improved with constexpr correctness, enabling more compile-time operations.

This commit makes progress towards C++26’s P3372 standard by enabling constexpr for std::deque and std::queue containers and their related internal operations. This allows more of their functionality to be evaluated at compile time. For debug builds, iterator instrumentation is disabled during constant evaluation to avoid issues with mutex locks and non-inline functions. Formatter specializations for queue and priority_queue are also made constexpr.

In Details

This patch implements _GLIBCXX26_CONSTEXPR for std::deque, std::queue, and associated algorithms and iterators, aligning with C++26 standards and P3372. It also makes formatter specializations for queue and priority_queue constexpr. Debug builds require special handling for iterator instrumentation due to mutexes and non-inline calls during constant evaluation, similar to prior work on std::vector. Certain __uninitialized_default_a overloads are marked _GLIBCXX20_CONSTEXPR as they don't depend on _Deque_iterator.

For Context
constexpr
A C++ keyword that denotes that a variable or function's value can be evaluated at compile time. This allows for optimizations and guarantees that certain operations can be performed during compilation rather than at runtime.
C++26
The anticipated next major revision of the C++ programming language standard, following C++23. Standards development is ongoing, and features are proposed and refined over several years.
std::deque
A C++ Standard Library container that provides random access to elements and supports efficient insertion and deletion at both the beginning and the end.
std::queue
A C++ Standard Library container adapter that provides a FIFO (First-In, First-Out) data structure. It typically uses another container like std::deque as its underlying storage.
P3372
A proposal for the C++ standard, likely related to constexpr support for standard library components. Specific proposals are identified by numbers within the C++ standardization process.
Filed Under: libstdc++constexprc++26containers