From 6365d1744b405cec48317e9597a80533acab0798 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 2 Jan 2018 08:53:02 -0800 Subject: Changes imported from Abseil "staging" branch: - d1a8e5ddbf9f96a4ca020260b21e03820c5ff966 Remove references to the non-existing StringPrintf API to... by Abseil Team - 64a422bc1620b29247a81fab2b08a7f23dfc1461 Add a copy and move constructor to FixedArray. This does... by Jon Cohen GitOrigin-RevId: d1a8e5ddbf9f96a4ca020260b21e03820c5ff966 Change-Id: I4388bdf1260702f2847307abbac4bf265e8cf90f --- absl/container/fixed_array.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'absl/container/fixed_array.h') diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h index 58240b4..ec6fced 100644 --- a/absl/container/fixed_array.h +++ b/absl/container/fixed_array.h @@ -47,6 +47,7 @@ #include "absl/base/macros.h" #include "absl/base/optimization.h" #include "absl/base/port.h" +#include "absl/memory/memory.h" namespace absl { @@ -107,6 +108,15 @@ class FixedArray { ? kInlineBytesDefault / sizeof(value_type) : inlined; + FixedArray(const FixedArray& other) : rep_(other.begin(), other.end()) {} + FixedArray(FixedArray&& other) noexcept( + // clang-format off + absl::allocator_is_nothrow>::value && + // clang-format on + std::is_nothrow_move_constructible::value) + : rep_(std::make_move_iterator(other.begin()), + std::make_move_iterator(other.end())) {} + // Creates an array object that can store `n` elements. // Note that trivially constructible elements will be uninitialized. explicit FixedArray(size_type n) : rep_(n) {} @@ -126,11 +136,9 @@ class FixedArray { ~FixedArray() {} - // Copy and move construction and assignment are deleted because (1) you can't - // copy or move an array, (2) assignment breaks the invariant that the size of - // a `FixedArray` never changes, and (3) there's no clear answer as to what - // should happen to a moved-from `FixedArray`. - FixedArray(const FixedArray&) = delete; + // Assignments are deleted because they break the invariant that the size of a + // `FixedArray` never changes. + void operator=(FixedArray&&) = delete; void operator=(const FixedArray&) = delete; // FixedArray::size() -- cgit v1.2.3