libstdc++: Make std::stack constexpr.
std::stack and its formatting capabilities are now constexpr.
The std::stack container adaptor and its associated formatting functions have been made constexpr, implementing parts of the P3372 and P3391R2 proposals. This allows std::stack to be used in compile-time contexts, enhancing its utility for constant evaluation and improving compile-time performance for certain applications.
In Details
This patch enables constexpr evaluation for std::stack and its relational operators and swap function, along with its formatter, aligning with proposals P3372 and P3391R2. The changes involve marking member functions and operators with _GLIBCXX26_CONSTEXPR and updating version definitions (constexpr_stack, __cpp_lib_constexpr_stack) to allow compile-time instantiation and manipulation of stack objects.
- constexpr
- A keyword in C++ that indicates a variable or function can be evaluated at compile time. This can lead to performance improvements and allows for compile-time computations.
- std::stack
- A C++ Standard Library container adaptor that provides a LIFO (Last-In, First-Out) stack data structure. It is typically implemented using other containers like
std::dequeorstd::vector. - P3372
- A C++ proposal aiming to introduce
constexprcapabilities for containers and adaptors, allowing them to be used in compile-time contexts. - P3391R2
- A C++ proposal, likely related to formatting or I/O, that introduces
constexprsupport for formatters. - libstdc++
- The standard C++ library implementation used by GCC.