Coverage Report

Created: 2026-01-09 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/abseil-cpp/absl/container/internal/container_memory.h
Line
Count
Source
1
// Copyright 2018 The Abseil Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_
16
#define ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_
17
18
#include <cassert>
19
#include <cstddef>
20
#include <cstdint>
21
#include <cstring>
22
#include <memory>
23
#include <new>
24
#include <tuple>
25
#include <type_traits>
26
#include <utility>
27
28
#include "absl/base/config.h"
29
#include "absl/hash/hash.h"
30
#include "absl/memory/memory.h"
31
#include "absl/meta/type_traits.h"
32
#include "absl/utility/utility.h"
33
34
#ifdef ABSL_HAVE_ADDRESS_SANITIZER
35
#include <sanitizer/asan_interface.h>
36
#endif
37
38
#ifdef ABSL_HAVE_MEMORY_SANITIZER
39
#include <sanitizer/msan_interface.h>
40
#endif
41
42
namespace absl {
43
ABSL_NAMESPACE_BEGIN
44
namespace container_internal {
45
46
template <size_t Alignment>
47
struct alignas(Alignment) AlignedType {
48
  // When alignment is sufficient for the allocated memory to store pointers,
49
  // include a pointer member so that swisstable backing arrays end up in the
50
  // pointer-containing partition for heap partitioning.
51
  std::conditional_t<(Alignment < alignof(void*)), char, void*> pointer;
52
};
53
54
// Allocates at least n bytes aligned to the specified alignment.
55
// Alignment must be a power of 2. It must be positive.
56
//
57
// Note that many allocators don't honor alignment requirements above certain
58
// threshold (usually either alignof(std::max_align_t) or alignof(void*)).
59
// Allocate() doesn't apply alignment corrections. If the underlying allocator
60
// returns insufficiently alignment pointer, that's what you are going to get.
61
template <size_t Alignment, class Alloc>
62
219k
void* Allocate(Alloc* alloc, size_t n) {
63
219k
  static_assert(Alignment > 0, "");
64
219k
  assert(n && "n must be positive");
65
219k
  using M = AlignedType<Alignment>;
66
219k
  using A = typename absl::allocator_traits<Alloc>::template rebind_alloc<M>;
67
219k
  using AT = typename absl::allocator_traits<Alloc>::template rebind_traits<M>;
68
  // On macOS, "mem_alloc" is a #define with one argument defined in
69
  // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
70
  // with the "foo(bar)" syntax.
71
219k
  A my_mem_alloc(*alloc);
72
219k
  void* p = AT::allocate(my_mem_alloc, (n + sizeof(M) - 1) / sizeof(M));
73
219k
  assert(reinterpret_cast<uintptr_t>(p) % Alignment == 0 &&
74
219k
         "allocator does not respect alignment");
75
219k
  return p;
76
219k
}
77
78
// Returns true if the destruction of the value with given Allocator will be
79
// trivial.
80
template <class Allocator, class ValueType>
81
constexpr auto IsDestructionTrivial() {
82
  constexpr bool result =
83
      std::is_trivially_destructible<ValueType>::value &&
84
      std::is_same<typename absl::allocator_traits<
85
                       Allocator>::template rebind_alloc<char>,
86
                   std::allocator<char>>::value;
87
  return std::integral_constant<bool, result>();
88
}
89
90
// The pointer must have been previously obtained by calling
91
// Allocate<Alignment>(alloc, n).
92
template <size_t Alignment, class Alloc>
93
219k
void Deallocate(Alloc* alloc, void* p, size_t n) {
94
219k
  static_assert(Alignment > 0, "");
95
219k
  assert(n && "n must be positive");
96
219k
  using M = AlignedType<Alignment>;
97
219k
  using A = typename absl::allocator_traits<Alloc>::template rebind_alloc<M>;
98
219k
  using AT = typename absl::allocator_traits<Alloc>::template rebind_traits<M>;
99
  // On macOS, "mem_alloc" is a #define with one argument defined in
100
  // rpc/types.h, so we can't name the variable "mem_alloc" and initialize it
101
  // with the "foo(bar)" syntax.
102
219k
  A my_mem_alloc(*alloc);
103
219k
  AT::deallocate(my_mem_alloc, static_cast<M*>(p),
104
219k
                 (n + sizeof(M) - 1) / sizeof(M));
105
219k
}
106
107
namespace memory_internal {
108
109
// Constructs T into uninitialized storage pointed by `ptr` using the args
110
// specified in the tuple.
111
template <class Alloc, class T, class Tuple, size_t... I>
112
void ConstructFromTupleImpl(Alloc* alloc, T* ptr, Tuple&& t,
113
                            absl::index_sequence<I...>) {
114
  absl::allocator_traits<Alloc>::construct(
115
      *alloc, ptr, std::get<I>(std::forward<Tuple>(t))...);
116
}
117
118
template <class T, class F>
119
struct WithConstructedImplF {
120
  template <class... Args>
121
  decltype(std::declval<F>()(std::declval<T>())) operator()(
122
      Args&&... args) const {
123
    return std::forward<F>(f)(T(std::forward<Args>(args)...));
124
  }
125
  F&& f;
126
};
127
128
template <class T, class Tuple, size_t... Is, class F>
129
decltype(std::declval<F>()(std::declval<T>())) WithConstructedImpl(
130
    Tuple&& t, absl::index_sequence<Is...>, F&& f) {
131
  return WithConstructedImplF<T, F>{std::forward<F>(f)}(
132
      std::get<Is>(std::forward<Tuple>(t))...);
133
}
134
135
template <class T, size_t... Is>
136
auto TupleRefImpl(T&& t, absl::index_sequence<Is...>)
137
    -> decltype(std::forward_as_tuple(std::get<Is>(std::forward<T>(t))...)) {
138
  // NOLINTNEXTLINE(bugprone-use-after-move)
139
  return std::forward_as_tuple(std::get<Is>(std::forward<T>(t))...);
140
}
141
142
// Returns a tuple of references to the elements of the input tuple. T must be a
143
// tuple.
144
template <class T>
145
auto TupleRef(T&& t) -> decltype(TupleRefImpl(
146
    std::forward<T>(t),
147
    absl::make_index_sequence<
148
        std::tuple_size<typename std::decay<T>::type>::value>())) {
149
  return TupleRefImpl(
150
      std::forward<T>(t),
151
      absl::make_index_sequence<
152
          std::tuple_size<typename std::decay<T>::type>::value>());
153
}
154
155
template <class F, class K, class V>
156
decltype(std::declval<F>()(std::declval<const K&>(), std::piecewise_construct,
157
                           std::declval<std::tuple<K>>(), std::declval<V>()))
158
DecomposePairImpl(F&& f, std::pair<std::tuple<K>, V> p) {
159
  const auto& key = std::get<0>(p.first);
160
  return std::forward<F>(f)(key, std::piecewise_construct, std::move(p.first),
161
                            std::move(p.second));
162
}
163
164
}  // namespace memory_internal
165
166
// Constructs T into uninitialized storage pointed by `ptr` using the args
167
// specified in the tuple.
168
template <class Alloc, class T, class Tuple>
169
void ConstructFromTuple(Alloc* alloc, T* ptr, Tuple&& t) {
170
  memory_internal::ConstructFromTupleImpl(
171
      alloc, ptr, std::forward<Tuple>(t),
172
      absl::make_index_sequence<
173
          std::tuple_size<typename std::decay<Tuple>::type>::value>());
174
}
175
176
// Constructs T using the args specified in the tuple and calls F with the
177
// constructed value.
178
template <class T, class Tuple, class F>
179
decltype(std::declval<F>()(std::declval<T>())) WithConstructed(Tuple&& t,
180
                                                               F&& f) {
181
  return memory_internal::WithConstructedImpl<T>(
182
      std::forward<Tuple>(t),
183
      absl::make_index_sequence<
184
          std::tuple_size<typename std::decay<Tuple>::type>::value>(),
185
      std::forward<F>(f));
186
}
187
188
// Given arguments of an std::pair's constructor, PairArgs() returns a pair of
189
// tuples with references to the passed arguments. The tuples contain
190
// constructor arguments for the first and the second elements of the pair.
191
//
192
// The following two snippets are equivalent.
193
//
194
// 1. std::pair<F, S> p(args...);
195
//
196
// 2. auto a = PairArgs(args...);
197
//    std::pair<F, S> p(std::piecewise_construct,
198
//                      std::move(a.first), std::move(a.second));
199
0
inline std::pair<std::tuple<>, std::tuple<>> PairArgs() { return {}; }
200
template <class F, class S>
201
std::pair<std::tuple<F&&>, std::tuple<S&&>> PairArgs(F&& f, S&& s) {
202
  return {std::piecewise_construct, std::forward_as_tuple(std::forward<F>(f)),
203
          std::forward_as_tuple(std::forward<S>(s))};
204
}
205
template <class F, class S>
206
std::pair<std::tuple<const F&>, std::tuple<const S&>> PairArgs(
207
    const std::pair<F, S>& p) {
208
  return PairArgs(p.first, p.second);
209
}
210
template <class F, class S>
211
std::pair<std::tuple<F&&>, std::tuple<S&&>> PairArgs(std::pair<F, S>&& p) {
212
  return PairArgs(std::forward<F>(p.first), std::forward<S>(p.second));
213
}
214
template <class F, class S>
215
auto PairArgs(std::piecewise_construct_t, F&& f, S&& s)
216
    -> decltype(std::make_pair(memory_internal::TupleRef(std::forward<F>(f)),
217
                               memory_internal::TupleRef(std::forward<S>(s)))) {
218
  return std::make_pair(memory_internal::TupleRef(std::forward<F>(f)),
219
                        memory_internal::TupleRef(std::forward<S>(s)));
220
}
221
222
// A helper function for implementing apply() in map policies.
223
template <class F, class... Args>
224
auto DecomposePair(F&& f, Args&&... args)
225
    -> decltype(memory_internal::DecomposePairImpl(
226
        std::forward<F>(f), PairArgs(std::forward<Args>(args)...))) {
227
  return memory_internal::DecomposePairImpl(
228
      std::forward<F>(f), PairArgs(std::forward<Args>(args)...));
229
}
230
231
// A helper function for implementing apply() in set policies.
232
template <class F, class Arg>
233
decltype(std::declval<F>()(std::declval<const Arg&>(), std::declval<Arg>()))
234
DecomposeValue(F&& f, Arg&& arg) {
235
  const auto& key = arg;
236
  return std::forward<F>(f)(key, std::forward<Arg>(arg));
237
}
238
239
// Helper functions for asan and msan.
240
538k
inline void SanitizerPoisonMemoryRegion(const void* m, size_t s) {
241
#ifdef ABSL_HAVE_ADDRESS_SANITIZER
242
  ASAN_POISON_MEMORY_REGION(m, s);
243
#endif
244
#ifdef ABSL_HAVE_MEMORY_SANITIZER
245
  __msan_poison(m, s);
246
#endif
247
538k
  (void)m;
248
538k
  (void)s;
249
538k
}
250
251
9.52M
inline void SanitizerUnpoisonMemoryRegion(const void* m, size_t s) {
252
#ifdef ABSL_HAVE_ADDRESS_SANITIZER
253
  ASAN_UNPOISON_MEMORY_REGION(m, s);
254
#endif
255
#ifdef ABSL_HAVE_MEMORY_SANITIZER
256
  __msan_unpoison(m, s);
257
#endif
258
9.52M
  (void)m;
259
9.52M
  (void)s;
260
9.52M
}
261
262
template <typename T>
263
inline void SanitizerPoisonObject(const T* object) {
264
  SanitizerPoisonMemoryRegion(object, sizeof(T));
265
}
266
267
template <typename T>
268
inline void SanitizerUnpoisonObject(const T* object) {
269
  SanitizerUnpoisonMemoryRegion(object, sizeof(T));
270
}
271
272
namespace memory_internal {
273
274
// If Pair is a standard-layout type, OffsetOf<Pair>::kFirst and
275
// OffsetOf<Pair>::kSecond are equivalent to offsetof(Pair, first) and
276
// offsetof(Pair, second) respectively. Otherwise they are -1.
277
//
278
// The purpose of OffsetOf is to avoid calling offsetof() on non-standard-layout
279
// type, which is non-portable.
280
template <class Pair, class = std::true_type>
281
struct OffsetOf {
282
  static constexpr size_t kFirst = static_cast<size_t>(-1);
283
  static constexpr size_t kSecond = static_cast<size_t>(-1);
284
};
285
286
template <class Pair>
287
struct OffsetOf<Pair, typename std::is_standard_layout<Pair>::type> {
288
  static constexpr size_t kFirst = offsetof(Pair, first);
289
  static constexpr size_t kSecond = offsetof(Pair, second);
290
};
291
292
template <class K, class V>
293
struct IsLayoutCompatible {
294
 private:
295
  struct Pair {
296
    K first;
297
    V second;
298
  };
299
300
  // Is P layout-compatible with Pair?
301
  template <class P>
302
  static constexpr bool LayoutCompatible() {
303
    return std::is_standard_layout<P>() && sizeof(P) == sizeof(Pair) &&
304
           alignof(P) == alignof(Pair) &&
305
           memory_internal::OffsetOf<P>::kFirst ==
306
               memory_internal::OffsetOf<Pair>::kFirst &&
307
           memory_internal::OffsetOf<P>::kSecond ==
308
               memory_internal::OffsetOf<Pair>::kSecond;
309
  }
310
311
 public:
312
  // Whether pair<const K, V> and pair<K, V> are layout-compatible. If they are,
313
  // then it is safe to store them in a union and read from either.
314
  static constexpr bool value = std::is_standard_layout<K>() &&
315
                                std::is_standard_layout<Pair>() &&
316
                                memory_internal::OffsetOf<Pair>::kFirst == 0 &&
317
                                LayoutCompatible<std::pair<K, V>>() &&
318
                                LayoutCompatible<std::pair<const K, V>>();
319
};
320
321
}  // namespace memory_internal
322
323
// The internal storage type for key-value containers like flat_hash_map.
324
//
325
// It is convenient for the value_type of a flat_hash_map<K, V> to be
326
// pair<const K, V>; the "const K" prevents accidental modification of the key
327
// when dealing with the reference returned from find() and similar methods.
328
// However, this creates other problems; we want to be able to emplace(K, V)
329
// efficiently with move operations, and similarly be able to move a
330
// pair<K, V> in insert().
331
//
332
// The solution is this union, which aliases the const and non-const versions
333
// of the pair. This also allows flat_hash_map<const K, V> to work, even though
334
// that has the same efficiency issues with move in emplace() and insert() -
335
// but people do it anyway.
336
//
337
// If kMutableKeys is false, only the value member can be accessed.
338
//
339
// If kMutableKeys is true, key can be accessed through all slots while value
340
// and mutable_value must be accessed only via INITIALIZED slots. Slots are
341
// created and destroyed via mutable_value so that the key can be moved later.
342
//
343
// Accessing one of the union fields while the other is active is safe as
344
// long as they are layout-compatible, which is guaranteed by the definition of
345
// kMutableKeys. For C++11, the relevant section of the standard is
346
// https://timsong-cpp.github.io/cppwp/n3337/class.mem#19 (9.2.19)
347
template <class K, class V>
348
union map_slot_type {
349
  map_slot_type() {}
350
  ~map_slot_type() = delete;
351
  using value_type = std::pair<const K, V>;
352
  using mutable_value_type =
353
      std::pair<absl::remove_const_t<K>, absl::remove_const_t<V>>;
354
355
  value_type value;
356
  mutable_value_type mutable_value;
357
  absl::remove_const_t<K> key;
358
};
359
360
template <class K, class V>
361
struct map_slot_policy {
362
  using slot_type = map_slot_type<K, V>;
363
  using value_type = std::pair<const K, V>;
364
  using mutable_value_type =
365
      std::pair<absl::remove_const_t<K>, absl::remove_const_t<V>>;
366
367
 private:
368
  static void emplace(slot_type* slot) {
369
    // The construction of union doesn't do anything at runtime but it allows us
370
    // to access its members without violating aliasing rules.
371
    new (slot) slot_type;
372
  }
373
  // If pair<const K, V> and pair<K, V> are layout-compatible, we can accept one
374
  // or the other via slot_type. We are also free to access the key via
375
  // slot_type::key in this case.
376
  using kMutableKeys = memory_internal::IsLayoutCompatible<K, V>;
377
378
 public:
379
  static value_type& element(slot_type* slot) { return slot->value; }
380
  static const value_type& element(const slot_type* slot) {
381
    return slot->value;
382
  }
383
384
  static K& mutable_key(slot_type* slot) {
385
    // Still check for kMutableKeys so that we can avoid calling std::launder
386
    // unless necessary because it can interfere with optimizations.
387
    return kMutableKeys::value ? slot->key
388
                               : *std::launder(const_cast<K*>(
389
                                     std::addressof(slot->value.first)));
390
  }
391
392
  static const K& key(const slot_type* slot) {
393
    return kMutableKeys::value ? slot->key : slot->value.first;
394
  }
395
396
  template <class Allocator, class... Args>
397
  static void construct(Allocator* alloc, slot_type* slot, Args&&... args) {
398
    emplace(slot);
399
    if (kMutableKeys::value) {
400
      absl::allocator_traits<Allocator>::construct(*alloc, &slot->mutable_value,
401
                                                   std::forward<Args>(args)...);
402
    } else {
403
      absl::allocator_traits<Allocator>::construct(*alloc, &slot->value,
404
                                                   std::forward<Args>(args)...);
405
    }
406
  }
407
408
  // Construct this slot by moving from another slot.
409
  template <class Allocator>
410
  static void construct(Allocator* alloc, slot_type* slot, slot_type* other) {
411
    emplace(slot);
412
    if (kMutableKeys::value) {
413
      absl::allocator_traits<Allocator>::construct(
414
          *alloc, &slot->mutable_value, std::move(other->mutable_value));
415
    } else {
416
      absl::allocator_traits<Allocator>::construct(*alloc, &slot->value,
417
                                                   std::move(other->value));
418
    }
419
  }
420
421
  // Construct this slot by copying from another slot.
422
  template <class Allocator>
423
  static void construct(Allocator* alloc, slot_type* slot,
424
                        const slot_type* other) {
425
    emplace(slot);
426
    absl::allocator_traits<Allocator>::construct(*alloc, &slot->value,
427
                                                 other->value);
428
  }
429
430
  template <class Allocator>
431
  static auto destroy(Allocator* alloc, slot_type* slot) {
432
    if (kMutableKeys::value) {
433
      absl::allocator_traits<Allocator>::destroy(*alloc, &slot->mutable_value);
434
    } else {
435
      absl::allocator_traits<Allocator>::destroy(*alloc, &slot->value);
436
    }
437
    return IsDestructionTrivial<Allocator, value_type>();
438
  }
439
440
  template <class Allocator>
441
  static auto transfer(Allocator* alloc, slot_type* new_slot,
442
                       slot_type* old_slot) {
443
    // This should really just be
444
    // typename absl::is_trivially_relocatable<value_type>::type()
445
    // but std::pair is not trivially copyable in C++23 in some standard
446
    // library versions.
447
    // See https://github.com/llvm/llvm-project/pull/95444 for instance.
448
    auto is_relocatable = typename std::conjunction<
449
        absl::is_trivially_relocatable<typename value_type::first_type>,
450
        absl::is_trivially_relocatable<typename value_type::second_type>>::
451
        type();
452
453
    emplace(new_slot);
454
    if (is_relocatable) {
455
      // TODO(b/247130232,b/251814870): remove casts after fixing warnings.
456
      std::memcpy(static_cast<void*>(std::launder(&new_slot->value)),
457
                  static_cast<const void*>(&old_slot->value),
458
                  sizeof(value_type));
459
      return is_relocatable;
460
    }
461
462
    if (kMutableKeys::value) {
463
      absl::allocator_traits<Allocator>::construct(
464
          *alloc, &new_slot->mutable_value, std::move(old_slot->mutable_value));
465
    } else {
466
      absl::allocator_traits<Allocator>::construct(*alloc, &new_slot->value,
467
                                                   std::move(old_slot->value));
468
    }
469
    destroy(alloc, old_slot);
470
    return is_relocatable;
471
  }
472
};
473
474
// Suppress erroneous uninitialized memory errors on GCC. For example, GCC
475
// thinks that the call to slot_array() in find_or_prepare_insert() is reading
476
// uninitialized memory, but slot_array is only called there when the table is
477
// non-empty and this memory is initialized when the table is non-empty.
478
#if !defined(__clang__) && defined(__GNUC__)
479
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(x)                    \
480
  _Pragma("GCC diagnostic push")                                   \
481
      _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")  \
482
          _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") x; \
483
  _Pragma("GCC diagnostic pop")
484
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(x) \
485
  ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(return x)
486
#else
487
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(x) x
488
103M
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(x) return x
489
#endif
490
491
// Variadic arguments hash function that ignore the rest of the arguments.
492
// Useful for usage with policy traits.
493
template <class Hash, bool kIsDefault>
494
struct HashElement {
495
  HashElement(const Hash& h, size_t s) : hash(h), seed(s) {}
496
497
  template <class K, class... Args>
498
  size_t operator()(const K& key, Args&&...) const {
499
    if constexpr (kIsDefault) {
500
      // TODO(b/384509507): resolve `no header providing
501
      // "absl::hash_internal::SupportsHashWithSeed" is directly included`.
502
      // Maybe we should make "internal/hash.h" be a separate library.
503
      return absl::hash_internal::HashWithSeed().hash(hash, key, seed);
504
    }
505
    // NOLINTNEXTLINE(clang-diagnostic-sign-conversion)
506
    return hash(key) ^ seed;
507
  }
508
  const Hash& hash;
509
  size_t seed;
510
};
511
512
// No arguments function hash function for a specific key.
513
template <class Hash, class Key, bool kIsDefault>
514
struct HashKey {
515
  HashKey(const Hash& h, const Key& k) : hash(h), key(k) {}
516
517
  size_t operator()(size_t seed) const {
518
    return HashElement<Hash, kIsDefault>{hash, seed}(key);
519
  }
520
  const Hash& hash;
521
  const Key& key;
522
};
523
524
// Variadic arguments equality function that ignore the rest of the arguments.
525
// Useful for usage with policy traits.
526
template <class K1, class KeyEqual>
527
struct EqualElement {
528
  template <class K2, class... Args>
529
  bool operator()(const K2& lhs, Args&&...) const {
530
    ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(eq(lhs, rhs));
531
  }
532
  const K1& rhs;
533
  const KeyEqual& eq;
534
};
535
536
// Type erased function for computing hash of the slot.
537
using HashSlotFn = size_t (*)(const void* hash_fn, void* slot, size_t seed);
538
539
// Type erased function to apply `Fn` to data inside of the `slot`.
540
// The data is expected to have type `T`.
541
template <class Fn, class T, bool kIsDefault>
542
size_t TypeErasedApplyToSlotFn(const void* fn, void* slot, size_t seed) {
543
  const auto* f = static_cast<const Fn*>(fn);
544
  return HashElement<Fn, kIsDefault>{*f, seed}(*static_cast<const T*>(slot));
545
}
546
547
// Type erased function to apply `Fn` to data inside of the `*slot_ptr`.
548
// The data is expected to have type `T`.
549
template <class Fn, class T, bool kIsDefault>
550
size_t TypeErasedDerefAndApplyToSlotFn(const void* fn, void* slot_ptr,
551
                                       size_t seed) {
552
  const auto* f = static_cast<const Fn*>(fn);
553
  const T* slot = *static_cast<const T**>(slot_ptr);
554
  return HashElement<Fn, kIsDefault>{*f, seed}(*slot);
555
}
556
557
}  // namespace container_internal
558
ABSL_NAMESPACE_END
559
}  // namespace absl
560
561
#endif  // ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_