Repository navigation
Span: drop the <iterator> include - #8
Merged
Merged
Conversation
Span.h included <iterator> only for std::reverse_iterator<T*> in rbegin/rend. <span> already makes std::reverse_iterator available (std::span's own reverse_iterator member type needs it) on libc++, libstdc++ and MSVC STL. Saves ~11% of the Span.h/Containers parse cost in isolation, and ~1.5-5% per TU in a downstream project under _LIBCPP_REMOVE_TRANSITIVE_INCLUDES.
The windows-latest image moved to MSVC 14.52, whose STL refuses any Clang older than 22 (STL1000). The x64 lane picked up the image's standalone LLVM from PATH, so it failed before compiling anything. Both clang-cl lanes now take the clang-cl under VC\Tools\Llvm, the one the STL was released against, and hand it to CMake as CC and CXX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Span.hincluded<iterator>only forstd::reverse_iterator<T*>inrbegin/rend.<iterator>is a heavy header, andSpan.his reached fromContainers.hand so from most downstream translation units. Dropping it saves about 11% of theSpan.h/Containers.hparse cost in isolation, and about 1.5–5% per TU in a downstream project built with_LIBCPP_REMOVE_TRANSITIVE_INCLUDES.Portability
<span>already makesstd::reverse_iteratoravailable on all three standard libraries, becausestd::span's ownreverse_iteratormember type needs it:<span>includes<__iterator/reverse_iterator.h>.<span>includes<bits/stl_iterator.h>. Verified that a TU including only<span>and usingstd::reverse_iterator<int*>compiles with g++ and with clang + libstdc++ at C++20, C++23 and C++26.<span>includes<xutility>, which definesreverse_iterator.Verification
Span.halone 1142M → 998M (-12.6%),Containers.h-10.9%; downstreamCore.h-1.7%,Strings.cpp-4.9%.CI fix (second commit)
The
windows-latestimage moved to MSVC STL 14.52, which refuses Clang older than 22 (STL1000), so "Windows Clang" failed before compiling anything — on any branch, not because of this change. The second commit builds both clang-cl lanes with the clang-cl inside Visual Studio (VC\Tools\Llvm) instead of the image's standalone LLVM onPATH, the same fix eacp took. It is included here so this PR's CI can go green.