[libcxx-commits] [libcxx] e48e4e9 - [libc++] Guard container benchmarks on library availability (#215408)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 12 09:46:48 PDT 2026
Author: Louis Dionne
Date: 2026-08-12T12:46:41-04:00
New Revision: e48e4e97d7960c689ccc4cbef9aee970eb560f97
URL: https://github.com/llvm/llvm-project/commit/e48e4e97d7960c689ccc4cbef9aee970eb560f97
DIFF: https://github.com/llvm/llvm-project/commit/e48e4e97d7960c689ccc4cbef9aee970eb560f97.diff
LOG: [libc++] Guard container benchmarks on library availability (#215408)
Instead of using TEST_STD_VER, use FTMs or requires clauses to enable
benchmarks for some recent features like `append_range`. This is needed
since older versions of the library don't provide these features, so the
container benchmarks as a whole would fail to compile instead of just a
few methods being disabled.
Added:
Modified:
libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
libcxx/test/benchmarks/containers/string.bench.cpp
Removed:
################################################################################
diff --git a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
index 82ceefa0459ef..72fd0ac9bfa0e 100644
--- a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
@@ -547,7 +547,7 @@ void associative_container_benchmarks(std::string container) {
}
});
-#if TEST_STD_VER >= 23
+#if defined(__cpp_lib_ranges_zip) && __cpp_lib_ranges_zip >= 202110L
bench_non_empty("insert(iterator, iterator) (product_iterator from zip_view)", [=](auto& st) {
const std::size_t size = st.range(0);
std::vector<Key> keys = generate_unique_keys(size + (size / 10));
diff --git a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
index 3ddeb7571f2d4..c6cf6fbafcb9e 100644
--- a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
@@ -398,7 +398,7 @@ void sequence_container_benchmarks(std::string container) {
}
});
-#if TEST_STD_VER >= 23
+#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
for (auto gen : generators)
bench("append_range() (into empty container)" + tostr(gen), [gen](auto& state) {
auto const size = state.range(0);
diff --git a/libcxx/test/benchmarks/containers/string.bench.cpp b/libcxx/test/benchmarks/containers/string.bench.cpp
index 26e2f62ad57fe..49f688aedae5c 100644
--- a/libcxx/test/benchmarks/containers/string.bench.cpp
+++ b/libcxx/test/benchmarks/containers/string.bench.cpp
@@ -205,7 +205,7 @@ int main(int argc, char** argv) {
}
});
-#if TEST_STD_VER >= 23
+#if defined(__cpp_lib_string_resize_and_overwrite) && __cpp_lib_string_resize_and_overwrite >= 202110L
bench("std::basic_string::resize_and_overwrite()",
[]<class CharT>(std::type_identity<CharT>, benchmark::State& state) {
std::basic_string<CharT> str;
More information about the libcxx-commits
mailing list