[libcxx-commits] [libcxx] 427a5cf - [libc++] Add support for bounded iterators in std::array (#110729)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 06:23:32 PST 2024


Author: Louis Dionne
Date: 2024-11-07T09:23:21-05:00
New Revision: 427a5cf105c409993c812f4fb1868bac96fce0c5

URL: https://github.com/llvm/llvm-project/commit/427a5cf105c409993c812f4fb1868bac96fce0c5
DIFF: https://github.com/llvm/llvm-project/commit/427a5cf105c409993c812f4fb1868bac96fce0c5.diff

LOG: [libc++] Add support for bounded iterators in std::array (#110729)

This patch introduces a new kind of bounded iterator that knows the size
of its valid range at compile-time, as in std::array. This allows computing
the end of the range from the start of the range and the size, which requires
storing only the start of the range in the iterator instead of both the start
and the size (or start and end). The iterator wrapper is otherwise identical
in design to the existing __bounded_iter.

Since this requires changing the type of the iterators returned by
std::array, this new bounded iterator is controlled by an ABI flag.

As a drive-by, centralize the tests for std::array::operator[] and add
missing tests for OOB operator[] on non-empty arrays.

Fixes #70864

Added: 
    libcxx/include/__iterator/static_bounded_iter.h
    libcxx/test/std/containers/sequences/array/assert.back.pass.cpp
    libcxx/test/std/containers/sequences/array/assert.front.pass.cpp
    libcxx/test/std/containers/sequences/array/assert.indexing.pass.cpp
    libcxx/test/std/containers/sequences/array/assert.iterators.pass.cpp

Modified: 
    libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake
    libcxx/docs/Hardening.rst
    libcxx/docs/ReleaseNotes/20.rst
    libcxx/include/CMakeLists.txt
    libcxx/include/__configuration/abi.h
    libcxx/include/__iterator/bounded_iter.h
    libcxx/include/array
    libcxx/include/module.modulemap
    libcxx/test/libcxx/input.output/iostream.format/print.fun/transcoding.pass.cpp
    libcxx/utils/libcxx/test/features.py

Removed: 
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp


################################################################################error: too big or took too long to generate

        


More information about the libcxx-commits mailing list