diff options
author | Abseil Team <absl-team@google.com> | 2019-06-25T19·32-0700 |
---|---|---|
committer | Shaindel Schwartz <shaindel@google.com> | 2019-06-25T20·21-0400 |
commit | 72e09a54d993b192db32be14c65adf7e9bd08c31 (patch) | |
tree | 35c92ce978803f6848fbee35c697d8d578d29474 /absl/algorithm | |
parent | d65e19dfcd8697076f68598c0131c6930cdcd74d (diff) |
Export of internal Abseil changes.
-- 2ee5dbb79b56539b580c3a36eec5a025d08b7022 by Eric Fiselier <ericwf@google.com>: Unconditionally apply no-sanitize attributes. We currently fail to apply the attributes in open-source land because the build system doesn't define ADDRESS_SANITIZER like we expect. The attributes should have no effect when the sanitizers are disabled. PiperOrigin-RevId: 255024122 -- 5a123175146de14d04013862aa378f28f8eff73c by CJ Johnson <johnsoncj@google.com>: Updates the InputIterator-accepting member functions of InlinedVector to be cleaner/easier to read PiperOrigin-RevId: 254994794 -- a4bdb61407a76317810785a34e49f996699ab4a4 by Abseil Team <absl-team@google.com>: Added back c_move_backward which was previously deleted by mistake. PiperOrigin-RevId: 254990809 -- bc427ca5f7fb88a70ba3a676bb9c7ff829c65ae9 by CJ Johnson <johnsoncj@google.com>: Removes DestroyAndDeallocate() function from the internal details of InlinedVector because it ended up not being particularly useful PiperOrigin-RevId: 254981201 GitOrigin-RevId: 2ee5dbb79b56539b580c3a36eec5a025d08b7022 Change-Id: I825c6c0a2fcf13ed6e60d71224037a57d7068d55
Diffstat (limited to 'absl/algorithm')
-rw-r--r-- | absl/algorithm/container.h | 10 | ||||
-rw-r--r-- | absl/algorithm/container_test.cc | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/absl/algorithm/container.h b/absl/algorithm/container.h index 752e47b23939..c84de461ac28 100644 --- a/absl/algorithm/container.h +++ b/absl/algorithm/container.h @@ -510,6 +510,16 @@ OutputIterator c_move(C&& src, OutputIterator dest) { container_algorithm_internal::c_end(src), dest); } +// c_move_backward() +// +// Container-based version of the <algorithm> `std::move_backward()` function to +// move a container's elements into an iterator in reverse order. +template <typename C, typename BidirectionalIterator> +BidirectionalIterator c_move_backward(C&& src, BidirectionalIterator dest) { + return std::move_backward(container_algorithm_internal::c_begin(src), + container_algorithm_internal::c_end(src), dest); +} + // c_swap_ranges() // // Container-based version of the <algorithm> `std::swap_ranges()` function to diff --git a/absl/algorithm/container_test.cc b/absl/algorithm/container_test.cc index 04282b8947a0..86bf9d3ea327 100644 --- a/absl/algorithm/container_test.cc +++ b/absl/algorithm/container_test.cc @@ -636,6 +636,19 @@ TEST(MutatingTest, Move) { Pointee(5))); } +TEST(MutatingTest, MoveBackward) { + std::vector<std::unique_ptr<int>> actual; + actual.emplace_back(absl::make_unique<int>(1)); + actual.emplace_back(absl::make_unique<int>(2)); + actual.emplace_back(absl::make_unique<int>(3)); + actual.emplace_back(absl::make_unique<int>(4)); + actual.emplace_back(absl::make_unique<int>(5)); + auto subrange = absl::MakeSpan(actual.data(), 3); + absl::c_move_backward(subrange, actual.end()); + EXPECT_THAT(actual, ElementsAre(IsNull(), IsNull(), Pointee(1), Pointee(2), + Pointee(3))); +} + TEST(MutatingTest, MoveWithRvalue) { auto MakeRValueSrc = [] { std::vector<std::unique_ptr<int>> src; |