GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

libstdc++: Include range_access.h from <valarray> for C++11 and later.

The `<valarray>` header now includes `<bits/ranges_access.h>` for C++11 and later, providing `begin`/`end` support for valarrays.

The <valarray> header in libstdc++ now includes <bits/ranges_access.h> when compiling for C++11 or later. This change enables the use of range-based for loops and the std::begin and std::end functions with std::valarray. This brings std::valarray in line with other container-like types that have been updated to support range access as a defect report against C++11.

In Details

This commit implements part of P3016R6 by including <bits/ranges_access.h> from <valarray> for C++11 and later. This is treated as a DR against C++11, similar to changes for <optional> (LWG4131) and <stacktrace> (LWG3625). The change exposes begin/end for std::valarray, enabling range-based for loops.

For Context

This commit adds support for using range-based for loops with std::valarray in the C++ standard library. std::valarray is a container similar to std::vector, but optimized for numerical computations. This change allows you to iterate over the elements of a std::valarray using the range-based for loop syntax (for (auto x : my_valarray)).

Filed Under: libstdc++valarrayranges