aboutsummaryrefslogtreecommitdiff
path: root/absl/container/flat_hash_set.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2024-01-30 12:52:43 -0800
committerCopybara-Service <copybara-worker@google.com>2024-01-30 12:53:38 -0800
commitc44dd5acd7848a175d1fb939cdb81a4cf8d4c912 (patch)
tree4f853927f1aa61dc3fd658dbba141f6d9148b1db /absl/container/flat_hash_set.h
parent779a3565ac6c5b69dd1ab9183e500a27633117d5 (diff)
downloadabseil-c44dd5acd7848a175d1fb939cdb81a4cf8d4c912.tar.gz
abseil-c44dd5acd7848a175d1fb939cdb81a4cf8d4c912.tar.bz2
abseil-c44dd5acd7848a175d1fb939cdb81a4cf8d4c912.zip
Early return from destroy_slots for trivially destructible types in flat_hash_{*}.
PiperOrigin-RevId: 602813933 Change-Id: I744fe438281755a141b2fd47e54ab9c6c0fad5a3
Diffstat (limited to 'absl/container/flat_hash_set.h')
-rw-r--r--absl/container/flat_hash_set.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/absl/container/flat_hash_set.h b/absl/container/flat_hash_set.h
index a94a82a0..cd74923c 100644
--- a/absl/container/flat_hash_set.h
+++ b/absl/container/flat_hash_set.h
@@ -29,6 +29,7 @@
#ifndef ABSL_CONTAINER_FLAT_HASH_SET_H_
#define ABSL_CONTAINER_FLAT_HASH_SET_H_
+#include <memory>
#include <type_traits>
#include <utility>
@@ -473,9 +474,11 @@ struct FlatHashSetPolicy {
std::forward<Args>(args)...);
}
+ // Return std::true_type in case destroy is trivial.
template <class Allocator>
- static void destroy(Allocator* alloc, slot_type* slot) {
+ static auto destroy(Allocator* alloc, slot_type* slot) {
absl::allocator_traits<Allocator>::destroy(*alloc, slot);
+ return IsDestructionTrivial<Allocator, slot_type>();
}
static T& element(slot_type* slot) { return *slot; }