Libc++ 22.0.0 (In-Progress) Release Notes¶
Written by the Libc++ Team
Warning
These are in-progress notes for the upcoming libc++ 22.0.0 release. Release notes for previous releases can be found on the Download Page.
Introduction¶
This document contains the release notes for the libc++ C++ Standard Library, part of the LLVM Compiler Infrastructure, release 22.0.0. Here we describe the status of libc++ in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see the LLVM documentation. All LLVM releases may be downloaded from the LLVM releases web site.
For more information about libc++, please see the Libc++ Web Site or the LLVM Web Site.
Note that if you are reading this file from a Git checkout or the main Libc++ web page, this document applies to the next release, not the current one. To see the release notes for a specific release, please see the releases page.
What’s New in Libc++ 22.0.0?¶
Implemented Papers¶
P2592R3: Hashing support for
std::chronovalue classes (Github)P2321R2:
zip(Github)P2988R12:
std::optional<T&>(Github)P3044R2: sub-
string_viewfromstring(Github)P3223R2: Making
std::istream::ignoreless surprising (Github)P3060R3: Add
std::views::indices(n)(Github)P2404R3: Move-only types for
equality_comparable_with,totally_ordered_with, andthree_way_comparable_with(Github)P2641R4: Checking if a
unionalternative is active (std::is_within_lifetime) (Github)P2835R7: Expose
std::atomic_ref’s object address (Github)P2944R3: Comparisons for
reference_wrapper(Github)P3168R2: Give
std::optionalRange Support (guarded by-fexperimental-library, Github)P3567R2:
flat_meowFixes (Github)P3836R2: Make
optional<T&>trivially copyable (Github)P1789R3: Library Support for Expansion Statements (Github)
Improvements and New Features¶
The performance of associative and unordered containers has been significantly improved. This is an overview of the different functions and by up to how much they have been improved:
map::map(const map&): 2.3xmap::operator=(const map&): 11xunordered_set::unordered_set(const unordered_set&): 3.3xunordered_set::operator=(const unordered_set&): 5xeraseofmapandset: 2xfind(key)ofmap,set,multimapandmultiset: 2.3x(iterator, iterator)constructors ofmap,set,multimapandmultiset: 3xinsert(iterator, iterator)ofmap,set,multimapandmultiset: 2.5xerase(iterator, iterator)of the unordered containers: 1.9xmap::insert_or_assign: 2x
The performance of many algorithms has been improved. This is an overview of the different functions and by up to how much they have been improved:
std::findfor integral types: 2xstd::for_eachandranges::for_eachover the associative containers: 2xstd::rotate: 3xSome have been specifically optimized for segmented iterators:
std::distanceandstd::ranges::distanceon non-random-access iterators: 1600x{std,ranges}::{fill, fill_n}: 10xstd::{generate, generate_n}andstd::ranges::generate_n: 1.8x
std::search_nfor random access iterators now tries to skip elements. In contrived cases improvements of 70,000x have been observed.
There have also been performance improvements in other library facilities:
vector<bool>::reserve(): 2xdeque::append_range: 3.4xnum_get::do_getintegral overloads: 2.8xSome reallocations are now avoided in
std::filesystem::path::lexically_relative: 1.7xofstream::writepasses large strings to system calls directly instead of copying them in chunks into a bufferstd::alignis now an inline function, which allows the compiler to better optimize calls to it
std::atomic::waithas been refactored to accept more types to use platform native wait functions directly. This is guarded behind the ABI Macro_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE.Multiple internal types have been refactored to use
[[no_unique_address]], resulting in faster compile times and reduced debug information.
Deprecations and Removals¶
Potentially breaking changes¶
The algorithm for
multi{map,set}::findhas been modified such that it doesn’t necessarily return an iterator to the first equal element in the container. This was never guaranteed by the Standard, but libc++ previously happened to always return the first equal element, like other implementations do. Starting with this release, code relying on the first element being returned fromfindwill be broken, andlower_boundorequal_rangeshould be used instead.The ABI flag
_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBERhas been split off from_LIBCPP_ABI_NO_ITERATOR_BASES. If you are using this flag and care about ABI stability, you should set_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBERas well.
Announcements About Future Releases¶
ABI Affecting Changes¶
The ABI flag
_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBERhas been split off from_LIBCPP_ABI_NO_ITERATOR_BASES. If you are using this flag and care about ABI stability, you should set_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBERas well.The internal types
__map_value_compare,__unordered_map_hasher,__unordered_map_equal,__hash_map_hasherand__hash_map_equalhave been refactored to use_LIBCPP_COMPRESSED_ELEMENTinstead of potentially inheriting from the types they wrap. At this point in time we are not aware of any ABI changes caused by this.ranges::iota_viewis now aware of__int128. This causesiota_view::difference_typeto change fromlong longto__int128in some cases.std::allocatoris now trivially default constructible. The behaviour can be reverted by defining_LIBCPP_DEPRECATED_ABI_NON_TRIVIAL_ALLOCATOR. Please inform the libc++ team if you need this flag, since it will be removed in LLVM 24 if there is no evidence that it’s required.bitset::operator[]now returnsbool, making libc++ conforming. The behaviour can be reverted by defining_LIBCPP_DEPRECATED_ABI_BITSET_CONST_SUBSCRIPT_RETURN_REF. Please inform the libc++ team if you need this flag, since it will be removed in LLVM 24 if there is no evidence that it’s required.