aboutsummaryrefslogtreecommitdiffhomepage
path: root/absl/container/fixed_array.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2019-08-20 11:39:40 -0700
committerGravatar Xiaoyi Zhang <zhangxy@google.com>2019-08-20 15:59:49 -0400
commitf0afae0d49af3e15a7169e019634d7719143d94d (patch)
tree25923b3b33eb9c5a644fab14193195df7225401b /absl/container/fixed_array.h
parent0e7afdcbd24c7e5b7cab4e0217d8886f1525b520 (diff)
Export of internal Abseil changes
-- 0f6565955231dc74ebad62ef32a18c457afa2dc7 by Abseil Team <absl-team@google.com>: Document guarantee that we do not move from rvalue arguments if no insertion happens with absl::raw_hash_map::try_emplace, as done with std::unordered_map::try_emplace. PiperOrigin-RevId: 264430409 -- 292e6b9e08fa689e8400d7f2db94cbcab29d5889 by CJ Johnson <johnsoncj@google.com>: Removes use of aligned_storage in FixedArray and InlinedVector in favor of aligned char buffers. PiperOrigin-RevId: 264385559 -- aa0b19ad11ae5702022feee0e2e6434cfb28c9e9 by Derek Mauro <dmauro@google.com>: Make the unit tests for absl::any, absl::optional, and absl::variant no-ops when these types are just aliases for the corresponding std:: types. We have no way to fix standard library implementation bugs, so don't bother working around them. Also disable the corresponding exception-safety tests as well when exceptions are not enabled. Fixes https://github.com/abseil/abseil-cpp/pull/360 PiperOrigin-RevId: 264382050 -- 65896a911f36481b89b4712c83b91c90a76b64e8 by Abseil Team <absl-team@google.com>: Improve documentation on erase PiperOrigin-RevId: 264381266 GitOrigin-RevId: 0f6565955231dc74ebad62ef32a18c457afa2dc7 Change-Id: I74b9bd2ddf84526014104f17e87de70bd3fe65fa
Diffstat (limited to 'absl/container/fixed_array.h')
-rw-r--r--absl/container/fixed_array.h28
1 files changed, 11 insertions, 17 deletions
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h
index 2a8240a..70e94ad 100644
--- a/absl/container/fixed_array.h
+++ b/absl/container/fixed_array.h
@@ -31,7 +31,6 @@
#define ABSL_CONTAINER_FIXED_ARRAY_H_
#include <algorithm>
-#include <array>
#include <cassert>
#include <cstddef>
#include <initializer_list>
@@ -386,8 +385,7 @@ class FixedArray {
// error: call to int __builtin___sprintf_chk(etc...)
// will always overflow destination buffer [-Werror]
//
- template <typename OuterT = value_type,
- typename InnerT = absl::remove_extent_t<OuterT>,
+ template <typename OuterT, typename InnerT = absl::remove_extent_t<OuterT>,
size_t InnerN = std::extent<OuterT>::value>
struct StorageElementWrapper {
InnerT array[InnerN];
@@ -396,8 +394,6 @@ class FixedArray {
using StorageElement =
absl::conditional_t<std::is_array<value_type>::value,
StorageElementWrapper<value_type>, value_type>;
- using StorageElementBuffer =
- absl::aligned_storage_t<sizeof(StorageElement), alignof(StorageElement)>;
static pointer AsValueType(pointer ptr) { return ptr; }
static pointer AsValueType(StorageElementWrapper<value_type>* ptr) {
@@ -407,25 +403,25 @@ class FixedArray {
static_assert(sizeof(StorageElement) == sizeof(value_type), "");
static_assert(alignof(StorageElement) == alignof(value_type), "");
- struct NonEmptyInlinedStorage {
- StorageElement* data() {
- return reinterpret_cast<StorageElement*>(inlined_storage_.data());
- }
+ class NonEmptyInlinedStorage {
+ public:
+ StorageElement* data() { return reinterpret_cast<StorageElement*>(buff_); }
+ void AnnotateConstruct(size_type n);
+ void AnnotateDestruct(size_type n);
#ifdef ADDRESS_SANITIZER
void* RedzoneBegin() { return &redzone_begin_; }
void* RedzoneEnd() { return &redzone_end_ + 1; }
#endif // ADDRESS_SANITIZER
- void AnnotateConstruct(size_type);
- void AnnotateDestruct(size_type);
-
+ private:
ADDRESS_SANITIZER_REDZONE(redzone_begin_);
- std::array<StorageElementBuffer, inline_elements> inlined_storage_;
+ alignas(StorageElement) char buff_[sizeof(StorageElement[inline_elements])];
ADDRESS_SANITIZER_REDZONE(redzone_end_);
};
- struct EmptyInlinedStorage {
+ class EmptyInlinedStorage {
+ public:
StorageElement* data() { return nullptr; }
void AnnotateConstruct(size_type) {}
void AnnotateDestruct(size_type) {}
@@ -459,9 +455,7 @@ class FixedArray {
size_type size() const { return size_alloc_.template get<0>(); }
StorageElement* begin() const { return data_; }
StorageElement* end() const { return begin() + size(); }
- allocator_type& alloc() {
- return size_alloc_.template get<1>();
- }
+ allocator_type& alloc() { return size_alloc_.template get<1>(); }
private:
static bool UsingInlinedStorage(size_type n) {