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

Support constexpr formatting for vector<bool>::reference.

libstdc++ now supports constexpr formatting for vector<bool>::reference, enabling compile-time formatting.

The C++ standard library’s vector<bool>::reference type now supports constexpr formatting. This change, part of the P3391R2 “constexpr format” proposal, ensures that formatting operations on specialized boolean vectors can be performed at compile time, improving performance and enabling new compile-time checks.

In Details

The formatter<_Bit_reference, _CharT>::format specialization in libstdc++'s <vector> header has been updated to be constexpr under the __glibcxx_constexpr_format macro. This aligns with C++20's <format> library capabilities and enables compile-time evaluation of formatting for the vector<bool> proxy reference type, which was missed in a previous backport.

For Context
constexpr
A keyword in C++ that indicates a variable or function can be evaluated at compile time. This can lead to performance improvements and enables certain compile-time guarantees.
libstdc++
The standard C++ library implementation used by GCC.
vector<bool>
A specialized version of C++'s std::vector template that stores boolean values as individual bits for space efficiency. It uses a proxy reference type (reference) to allow modification of these bits.
P3391R2
A C++ standardization proposal (also known as "constexpr format") that introduces compile-time formatting capabilities to the standard library.
Filed Under: c++standard-libraryconstexpr