Consistently use [[maybe_unused]] in raw_hash_set.h for better compiler warning compatibility.
PiperOrigin-RevId: 778274640
Change-Id: I8075188f374b6a65743c1e7ffced5b0338c18031
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index 0cd8ad2..5f5a1d9 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -2388,7 +2388,7 @@
size_t capacity() const {
const size_t cap = common().capacity();
// Compiler complains when using functions in ASSUME so use local variable.
- ABSL_ATTRIBUTE_UNUSED static constexpr size_t kDefaultCapacity =
+ [[maybe_unused]] static constexpr size_t kDefaultCapacity =
DefaultCapacity();
ABSL_ASSUME(cap >= kDefaultCapacity);
return cap;
@@ -3155,8 +3155,7 @@
std::move(tmp));
}
- void annotate_for_bug_detection_on_move(
- ABSL_ATTRIBUTE_UNUSED raw_hash_set& that) {
+ void annotate_for_bug_detection_on_move([[maybe_unused]] raw_hash_set& that) {
// We only enable moved-from validation when generations are enabled (rather
// than using NDEBUG) to avoid issues in which NDEBUG is enabled in some
// translation units but not in others.
@@ -3307,7 +3306,7 @@
protected:
// Asserts for correctness that we run on find/find_or_prepare_insert.
template <class K>
- void AssertOnFind(ABSL_ATTRIBUTE_UNUSED const K& key) {
+ void AssertOnFind([[maybe_unused]] const K& key) {
AssertHashEqConsistent(key);
AssertNotDebugCapacity();
}
@@ -3366,7 +3365,7 @@
const bool is_key_equal = equal_to(key, to_slot(slot));
if (!is_key_equal) return;
- ABSL_ATTRIBUTE_UNUSED const bool is_hash_equal =
+ [[maybe_unused]] const bool is_hash_equal =
hash_of_arg == hash_of(to_slot(slot));
assert((!is_key_equal || is_hash_equal) &&
"eq(k1, k2) must imply that hash(k1) == hash(k2). "
@@ -3661,7 +3660,7 @@
c->erase_meta_only(it);
return 1;
}
- ABSL_ATTRIBUTE_UNUSED const size_t original_size_for_assert = c->size();
+ [[maybe_unused]] const size_t original_size_for_assert = c->size();
size_t num_deleted = 0;
using SlotType = typename Set::slot_type;
IterateOverFullSlots(