Skip to content

Commit

Permalink
Fix a bug in which we used propagate_on_container_copy_assignment in …
Browse files Browse the repository at this point in the history
…btree move assignment.

PiperOrigin-RevId: 565730754
Change-Id: Id828847d32c812736669803c179351433dda4aa6
  • Loading branch information
ezbr authored and copybara-github committed Sep 15, 2023
1 parent 49be2e6 commit f44e2ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions absl/container/btree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2515,14 +2515,14 @@ TEST(Btree, MoveAssignmentAllocatorPropagation) {
InstanceTracker tracker;

int64_t bytes1 = 0, bytes2 = 0;
PropagatingCountingAlloc<MovableOnlyInstance> allocator1(&bytes1);
PropagatingCountingAlloc<MovableOnlyInstance> allocator2(&bytes2);
MoveAssignPropagatingCountingAlloc<MovableOnlyInstance> allocator1(&bytes1);
MoveAssignPropagatingCountingAlloc<MovableOnlyInstance> allocator2(&bytes2);
std::less<MovableOnlyInstance> cmp;

// Test propagating allocator_type.
{
absl::btree_set<MovableOnlyInstance, std::less<MovableOnlyInstance>,
PropagatingCountingAlloc<MovableOnlyInstance>>
MoveAssignPropagatingCountingAlloc<MovableOnlyInstance>>
set1(cmp, allocator1), set2(cmp, allocator2);

for (int i = 0; i < 100; ++i) set1.insert(MovableOnlyInstance(i));
Expand Down
2 changes: 1 addition & 1 deletion absl/container/internal/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2423,7 +2423,7 @@ auto btree<P>::operator=(btree &&other) noexcept -> btree & {

using std::swap;
if (absl::allocator_traits<
allocator_type>::propagate_on_container_copy_assignment::value) {
allocator_type>::propagate_on_container_move_assignment::value) {
swap(root_, other.root_);
// Note: `rightmost_` also contains the allocator and the key comparator.
swap(rightmost_, other.rightmost_);
Expand Down

0 comments on commit f44e2ca

Please sign in to comment.