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

libstdc++: Implement LWG 3749 changes to common_iterator

Updates common_iterator to conform to LWG 3749, ensuring correct iterator category handling.

This change updates libstdc++‘s common_iterator to align with the C++ standard library’s LWG 3749 resolution. It modifies iterator_traits for common_iterator to correctly determine the iterator category, ensuring compatibility and proper behavior when dealing with different iterator and sentinel types. The changes involve adding a new helper, __detail::__common_iterator_iter_cat, and updating the iterator_traits definition.

In Details

This commit addresses LWG 3749 by refining the iterator_traits<common_iterator> implementation in libstdc++. The core change involves introducing __detail::__common_iterator_iter_cat to conditionally define iterator_category. This ensures that iterator_traits remains an aggregate type and correctly handles overlapping subobjects when the sentinel types differ, maintaining backward compatibility for users relying on these traits.

For Context
common_iterator
A C++ iterator adapter that can adapt to different underlying iterator types, often used in contexts like C++20 ranges to provide a unified view over heterogeneous sequences.
LWG 3749
A specific issue resolved by the Library Working Group of the C++ standards committee, related to the behavior and traits of the common_iterator.
iterator_traits
A C++ type trait that provides information about an iterator, such as its category, value type, difference type, and pointer/reference types. It's essential for generic algorithms.
iterator category
A classification of iterators (e.g., input, output, forward, bidirectional, random access) indicating the set of operations they support. This determines the efficiency and capabilities of algorithms that use them.
aggregate type
In C++, a class or struct that has no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions. Aggregate types can be initialized using brace-enclosed lists.
Filed Under: libstdc++iteratorC++standard library