aboutsummaryrefslogtreecommitdiff
path: root/absl/container/internal/test_allocator.h
diff options
context:
space:
mode:
authorEvan Brown <ezb@google.com>2023-10-03 10:01:17 -0700
committerCopybara-Service <copybara-worker@google.com>2023-10-03 10:02:13 -0700
commit22dc7911f9a4721f6dec0cc41a36fd204aa0e4f8 (patch)
treeab4a1e578b6e509612e47b208595bf8a4f790c5f /absl/container/internal/test_allocator.h
parent74a8f6faf075cd796885a77c5cbb9ef56f65f747 (diff)
downloadabseil-22dc7911f9a4721f6dec0cc41a36fd204aa0e4f8.tar.gz
abseil-22dc7911f9a4721f6dec0cc41a36fd204aa0e4f8.tar.bz2
abseil-22dc7911f9a4721f6dec0cc41a36fd204aa0e4f8.zip
Refactor swisstable copy/move assignment to fix issues with allocator propagation and improve performance.
Correctness: - We use swap to implement copy assignment and move assignment, which means that allocator propagation in copy/move assignment depends on `propagate_on_container_swap` in addition to `propagate_on_container_copy_assignment`/`propagate_on_container_move_assignment`. - In swap, if `propagate_on_container_swap` is `false` and `get_allocator() != other.get_allocator()`, the behavior is undefined (https://en.cppreference.com/w/cpp/container/unordered_set/swap) - we should assert that this UB case isn't happening. For this reason, we also delete the NoPropagateOn_Swap test case in raw_hash_set_allocator_test. Performance: - Don't rely on swap so we don't have to do unnecessary copying into the moved-from sets. - Don't use temp sets in move assignment. - Default the move constructor of CommonFields. - Avoid using exchange in raw_hash_set move constructor. - In `raw_hash_set(raw_hash_set&& that, const allocator_type& a)` with unequal allocators and in move assignment with non-propagating unequal allocators, move set keys instead of copying them. PiperOrigin-RevId: 570419290 Change-Id: I499e54f17d9cb0b0836601f5c06187d1f269a5b8
Diffstat (limited to 'absl/container/internal/test_allocator.h')
-rw-r--r--absl/container/internal/test_allocator.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/absl/container/internal/test_allocator.h b/absl/container/internal/test_allocator.h
index adccc214..8e365a3c 100644
--- a/absl/container/internal/test_allocator.h
+++ b/absl/container/internal/test_allocator.h
@@ -364,7 +364,7 @@ void TestSwapAllocPropagation() {
EXPECT_NE(c1.get_allocator(), c2.get_allocator());
if (IsAssertEnabled()) {
- EXPECT_DEATH(c2.swap(c1), "");
+ EXPECT_DEATH_IF_SUPPORTED(c2.swap(c1), "");
}
}
EXPECT_EQ(bytes1, 0);