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

libstdc++: Support integer-class sized range in inplace_vector.

Allows `inplace_vector` to accept ranges sized by integer-class types by casting the range size to `size_t`.

This commit enhances inplace_vector to support ranges sized by integer-class types. It casts the size of the input range to size_t after verifying that it fits within the remaining capacity, ensuring compatibility with such ranges. New tests were added to verify the functionality for construction, assignment, and insertion from ranges with integer-class size types, enhancing the robustness of the inplace_vector.

In Details

inplace_vector is a container in libstdc++ that stores elements in-place, without dynamic memory allocation. This commit allows inplace_vector's assign_range and append_range methods to accept ranges where ranges::distance(__rg) returns an integer-class type. The size of the range is cast to size_t after checking that it can fit in the inplace_vector. New test cases are added to cover the integer-class size type scenarios.

For Context

inplace_vector is a C++ standard library container similar to std::vector, but with a fixed capacity known at compile time. This optimization avoids dynamic memory allocation. This commit allows the inplace_vector to be initialized or assigned from a range of elements whose size is represented by an integer type (e.g., int, long) rather than the standard size_t. The code ensures that the integer size can be safely converted to a size_t before performing the operation.

Filed Under: libstdc++inplace_vectorcontainers