From aeb2dc9c34e2dbddb5762d2ffca356e23eb55b56 Mon Sep 17 00:00:00 2001 From: Evan Brown Date: Tue, 31 May 2022 09:13:25 -0700 Subject: Allow for using b-tree with `value_type`s that can only be constructed by the allocator (ignoring copy/move constructors). We were using `init_type`s for temp values that we would move into slots, but in this case, we need to have actual slots. We use node handles for managing slots outside of nodes. Also, in btree::copy_or_move_values_in_order, pass the slots from the iterators rather than references to values. This allows for moving from map keys instead of copying for standard layout types. In the test, fix a couple of ClangTidy warnings from missing includes and calling `new` instead of `make_unique`. PiperOrigin-RevId: 452062967 Change-Id: I870e89ae1aa5b3cfa62ae6e75b73ffc3d52e731c --- absl/container/internal/common.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'absl/container/internal/common.h') diff --git a/absl/container/internal/common.h b/absl/container/internal/common.h index 030e9d4a..416d9aa3 100644 --- a/absl/container/internal/common.h +++ b/absl/container/internal/common.h @@ -84,10 +84,11 @@ class node_handle_base { PolicyTraits::transfer(alloc(), slot(), s); } - struct move_tag_t {}; - node_handle_base(move_tag_t, const allocator_type& a, slot_type* s) + struct construct_tag_t {}; + template + node_handle_base(construct_tag_t, const allocator_type& a, Args&&... args) : alloc_(a) { - PolicyTraits::construct(alloc(), slot(), s); + PolicyTraits::construct(alloc(), slot(), std::forward(args)...); } void destroy() { @@ -186,8 +187,8 @@ struct CommonAccess { } template - static T Move(Args&&... args) { - return T(typename T::move_tag_t{}, std::forward(args)...); + static T Construct(Args&&... args) { + return T(typename T::construct_tag_t{}, std::forward(args)...); } }; -- cgit v1.2.3