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

Libstdc++: Add LWG 4440 feature-test macros to <iosfwd>.

Adds C++20 feature-test macros for spanstream and syncbuf to libstdc++'s <iosfwd>.

This commit adds C++20 feature-test macros __cpp_lib_spanstream and __cpp_lib_syncbuf to the <iosfwd> header in libstdc++. These macros indicate the availability of the std::spanstream and std::syncbuf features, respectively, as defined by the C++ standard. The macros are verified in the test suite.

In Details

The include/std/iosfwd header in libstdc++ now defines the feature-test macros __cpp_lib_spanstream and __cpp_lib_syncbuf. Unlike other feature-test macros, __cpp_lib_char8_t is defined in c++config and provided by all headers by default. The inclusion of these macros in <iosfwd> aligns libstdc++ with the C++20 standard requirements for these stream buffer facilities.

For Context
libstdc++
The C++ standard library implementation used by GCC.
feature-test macro
A macro defined in C++ standards to indicate the availability of specific language or library features. Programmers can use these macros to conditionally compile code based on standard support.
<iosfwd>
A C++ header that provides forward declarations for I/O stream-related classes and functions, allowing their use without including larger headers like <iostream>.
LWG
Library Working Group, a committee within the C++ Standards Committee responsible for the C++ Standard Library.
spanstream
A C++ stream class that operates on a contiguous sequence of characters, typically a std::span or a C-style array.
syncbuf
A C++ stream buffer that synchronizes output to an underlying stream buffer, useful for ensuring atomic output operations.
C++20
The 2020 edition of the C++ programming language standard, which introduced significant new features, including the Ranges library.
Filed Under: libstdc++c++20feature-test macro