Commit f44e2cac by Evan Brown Committed by Copybara-Service

Fix a bug in which we used propagate_on_container_copy_assignment in btree move assignment.

PiperOrigin-RevId: 565730754
Change-Id: Id828847d32c812736669803c179351433dda4aa6
parent 49be2e68
...@@ -2515,14 +2515,14 @@ TEST(Btree, MoveAssignmentAllocatorPropagation) { ...@@ -2515,14 +2515,14 @@ TEST(Btree, MoveAssignmentAllocatorPropagation) {
InstanceTracker tracker; InstanceTracker tracker;
int64_t bytes1 = 0, bytes2 = 0; int64_t bytes1 = 0, bytes2 = 0;
PropagatingCountingAlloc<MovableOnlyInstance> allocator1(&bytes1); MoveAssignPropagatingCountingAlloc<MovableOnlyInstance> allocator1(&bytes1);
PropagatingCountingAlloc<MovableOnlyInstance> allocator2(&bytes2); MoveAssignPropagatingCountingAlloc<MovableOnlyInstance> allocator2(&bytes2);
std::less<MovableOnlyInstance> cmp; std::less<MovableOnlyInstance> cmp;
// Test propagating allocator_type. // Test propagating allocator_type.
{ {
absl::btree_set<MovableOnlyInstance, std::less<MovableOnlyInstance>, absl::btree_set<MovableOnlyInstance, std::less<MovableOnlyInstance>,
PropagatingCountingAlloc<MovableOnlyInstance>> MoveAssignPropagatingCountingAlloc<MovableOnlyInstance>>
set1(cmp, allocator1), set2(cmp, allocator2); set1(cmp, allocator1), set2(cmp, allocator2);
for (int i = 0; i < 100; ++i) set1.insert(MovableOnlyInstance(i)); for (int i = 0; i < 100; ++i) set1.insert(MovableOnlyInstance(i));
......
...@@ -2423,7 +2423,7 @@ auto btree<P>::operator=(btree &&other) noexcept -> btree & { ...@@ -2423,7 +2423,7 @@ auto btree<P>::operator=(btree &&other) noexcept -> btree & {
using std::swap; using std::swap;
if (absl::allocator_traits< if (absl::allocator_traits<
allocator_type>::propagate_on_container_copy_assignment::value) { allocator_type>::propagate_on_container_move_assignment::value) {
swap(root_, other.root_); swap(root_, other.root_);
// Note: `rightmost_` also contains the allocator and the key comparator. // Note: `rightmost_` also contains the allocator and the key comparator.
swap(rightmost_, other.rightmost_); swap(rightmost_, other.rightmost_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment