summaryrefslogtreecommitdiff
path: root/absl/container/internal/btree.h
diff options
context:
space:
mode:
authorGravatar Evan Brown <ezb@google.com>2022-09-28 10:44:11 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-28 10:44:49 -0700
commit6d9ea2b46f470406e1f49acc30b272c6e9f6cc5e (patch)
tree06b005eae4626884acab33c51351dd1b62eac2a0 /absl/container/internal/btree.h
parentdf19c209961b44299aa047d7db0d3972d94a2d0b (diff)
Add common_policy_traits - a subset of hash_policy_traits that can be shared between raw_hash_set and btree.
Also remove the transfer implementations from btree_set.h and flat_hash_set.h, which are equivalent to the default implementations. Motivation: this will simplify upcoming changes related to trivial relocation. PiperOrigin-RevId: 477493403 Change-Id: I75babef4c93dec3a8105f86c58af54199bb1ec9c
Diffstat (limited to 'absl/container/internal/btree.h')
-rw-r--r--absl/container/internal/btree.h25
1 files changed, 2 insertions, 23 deletions
diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h
index 203823b0..ecf31bea 100644
--- a/absl/container/internal/btree.h
+++ b/absl/container/internal/btree.h
@@ -61,6 +61,7 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
#include "absl/container/internal/common.h"
+#include "absl/container/internal/common_policy_traits.h"
#include "absl/container/internal/compressed_tuple.h"
#include "absl/container/internal/container_memory.h"
#include "absl/container/internal/layout.h"
@@ -356,7 +357,7 @@ class map_value_compare {
template <typename Key, typename Compare, typename Alloc, int TargetNodeSize,
bool IsMulti, bool IsMap, typename SlotPolicy>
-struct common_params {
+struct common_params : common_policy_traits<SlotPolicy> {
using original_key_compare = Compare;
// If Compare is a common comparator for a string-like type, then we adapt it
@@ -438,28 +439,6 @@ struct common_params {
absl::conditional_t<(kNodeSlotSpace / sizeof(slot_type) >
(std::numeric_limits<uint8_t>::max)()),
uint16_t, uint8_t>; // NOLINT
-
- // The following methods are necessary for passing this struct as PolicyTraits
- // for node_handle and/or are used within btree.
- static value_type &element(slot_type *slot) {
- return slot_policy::element(slot);
- }
- static const value_type &element(const slot_type *slot) {
- return slot_policy::element(slot);
- }
- template <class... Args>
- static void construct(Alloc *alloc, slot_type *slot, Args &&...args) {
- slot_policy::construct(alloc, slot, std::forward<Args>(args)...);
- }
- static void construct(Alloc *alloc, slot_type *slot, slot_type *other) {
- slot_policy::construct(alloc, slot, other);
- }
- static void destroy(Alloc *alloc, slot_type *slot) {
- slot_policy::destroy(alloc, slot);
- }
- static void transfer(Alloc *alloc, slot_type *new_slot, slot_type *old_slot) {
- slot_policy::transfer(alloc, new_slot, old_slot);
- }
};
// An adapter class that converts a lower-bound compare into an upper-bound