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

Libstdc++ implements C++29 P3793R2 - Better shifting.

Adds C++29 bitwise shifting operations (`shl`, `shr`) to the standard library's `<bit>` header.

This commit implements the header functionalities for C++29’s P3793R2 proposal, commonly known as ‘Better shifting.’ It introduces new concepts like std::__signed_or_unsigned_integer and function templates std::shl and std::shr for more robust and expressive bitwise left and right shifts.

In Details

This patch adds support for C++29 P3793R2, 'Better shifting,' to libstdc++. It implements the <bit> header's shifting operations, including std::shl and std::shr. These functions provide a more semantically rich way to perform bitwise shifts compared to built-in operators, particularly by defining a new concept std::__signed_or_unsigned_integer to constrain the operations to appropriate integer types. The changes are integrated into the C++29 version definitions and exported accordingly.

For Context
libstdc++
The C++ standard library implementation used by GCC. It provides fundamental C++ functionalities like containers, algorithms, and I/O streams.
C++29
The upcoming standard version of the C++ programming language, which includes new features and library additions.
P3793R2
A C++ standardization proposal (numbered P3793, revision R2) that aims to introduce better bitwise shifting operations into the C++ standard library.
<bit> header
A C++ header file (introduced in C++20) that provides low-level bit manipulation operations.
concept
A C++20 feature that allows specifying requirements on template parameters, enabling more precise and readable template metaprogramming.
function template
A blueprint for generating functions in C++, allowing them to operate on different types without requiring explicit redefinition for each type.
std::shl
A function template added in C++29 that performs a bitwise left shift operation, likely with enhanced type safety or semantics over the built-in << operator.
std::shr
A function template added in C++29 that performs a bitwise right shift operation, likely with enhanced type safety or semantics over the built-in >> operator.
Filed Under: c++29libstdc++standard library