[libcxx-commits] [libcxx] [libc++] Avoid including vector in <functional> (PR #144310)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 25 23:45:24 PDT 2025
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/144310
>From eb6b3ae76f7307537e2d43852b99e2c86bc5efbf Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 16 Jun 2025 09:42:02 +0200
Subject: [PATCH] [libc++] Avoid including vector in <functional>
---
libcxx/include/__functional/boyer_moore_searcher.h | 4 +---
libcxx/include/functional | 4 ++++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__functional/boyer_moore_searcher.h b/libcxx/include/__functional/boyer_moore_searcher.h
index 7889232f4b919..88c6577f04dee 100644
--- a/libcxx/include/__functional/boyer_moore_searcher.h
+++ b/libcxx/include/__functional/boyer_moore_searcher.h
@@ -17,12 +17,10 @@
#include <__config>
#include <__functional/hash.h>
#include <__functional/operations.h>
-#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__memory/shared_ptr.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/pair.h>
-#include <__vector/vector.h>
#include <array>
#include <limits>
#include <unordered_map>
@@ -196,7 +194,7 @@ class boyer_moore_searcher {
if (__count == 0)
return;
- vector<difference_type> __scratch(__count);
+ auto __scratch = std::make_unique<difference_type[]>(__count);
__compute_bm_prefix(__first, __last, __pred, __scratch);
for (size_t __i = 0; __i <= __count; ++__i)
diff --git a/libcxx/include/functional b/libcxx/include/functional
index b121a19d6bcb3..c72d0931e4b92 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -599,6 +599,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited
# include <utility>
# include <vector>
# endif
+
+# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 23
+# include <__vector/vector.h>
+# endif
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
#endif // _LIBCPP_FUNCTIONAL
More information about the libcxx-commits
mailing list