Support C++20 iterators in raw_hash_map's random-access iterator detection
Missed in https://github.com/abseil/abseil-cpp/commit/9e764b4f25c33e3f2407f5f22e695ede41bf2ce0. Allows random-access iterators with a value-type `reference` (e.g. zip iterators) to hit this fast path, because of https://github.com/abseil/abseil-cpp/commit/ae4b0c5f096c1bc1c2562d7b35e6feb1ab4514ef.
PiperOrigin-RevId: 727356112
Change-Id: I4a2499cc1d0403b51a802297c84449531cfb9d5e
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel
index 0e30c8e..79db309 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -697,6 +697,7 @@
"//absl/base:core_headers",
"//absl/base:dynamic_annotations",
"//absl/base:endian",
+ "//absl/base:iterator_traits_internal",
"//absl/base:prefetch",
"//absl/base:raw_logging_internal",
"//absl/functional:function_ref",
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt
index 4dd12e1..3e83349 100644
--- a/absl/container/CMakeLists.txt
+++ b/absl/container/CMakeLists.txt
@@ -765,6 +765,7 @@
absl::hash_policy_traits
absl::hashtable_debug_hooks
absl::hashtablez_sampler
+ absl::iterator_traits_internal
absl::memory
absl::meta
absl::optional
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index f8eb70a..9236b88 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -196,6 +196,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/endian.h"
+#include "absl/base/internal/iterator_traits.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
#include "absl/base/optimization.h"
@@ -1601,10 +1602,8 @@
if (bucket_count != 0) {
return bucket_count;
}
- using InputIterCategory =
- typename std::iterator_traits<InputIter>::iterator_category;
- if (std::is_base_of<std::random_access_iterator_tag,
- InputIterCategory>::value) {
+ if (base_internal::IsAtLeastIterator<std::random_access_iterator_tag,
+ InputIter>()) {
return GrowthToLowerboundCapacity(
static_cast<size_t>(std::distance(first, last)));
}