about summary refs log tree commit diff
path: root/absl/container/internal/inlined_vector.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-05-22T12·06-0700
committerDerek Mauro <dmauro@google.com>2019-05-22T13·07-0400
commitce65f5ac3cbf897bb5e3de1a51d80fd00866abaa (patch)
tree60b88792ce60bf1dd8569b684eb3c3ed9b866e2d /absl/container/internal/inlined_vector.h
parenta18fc7461e7409c2ad64e28537261db1e02e76fa (diff)
Export of internal Abseil changes.
--
1edfe05ddddca43e7650b2d790df7c8498c0e588 by Abseil Team <absl-team@google.com>:

Adding an assert to catch various misuses of std::optional.

PiperOrigin-RevId: 249427865

--
45463bbb7e59dfbc584b2f024368a63db98bd7a8 by CJ Johnson <johnsoncj@google.com>:

Migrates internal member function GetAllocator() to GetAllocPtr() and changes the return type to pointer instead of reference to avoid unnecessary copy in DestroyElements(...)

PiperOrigin-RevId: 249319571

--
507835be22af85676143ee0c43a80a52bc32094c by Abseil Team <absl-team@google.com>:

Fix -Wstring-conversion in GetEnvVar (Windows implementation).

PiperOrigin-RevId: 249201897
GitOrigin-RevId: 1edfe05ddddca43e7650b2d790df7c8498c0e588
Change-Id: I9300131887ee507cf80d399c724cf87341e4f11a
Diffstat (limited to 'absl/container/internal/inlined_vector.h')
-rw-r--r--absl/container/internal/inlined_vector.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h
index 4589ce0837a4..a2b3d24d98e9 100644
--- a/absl/container/internal/inlined_vector.h
+++ b/absl/container/internal/inlined_vector.h
@@ -33,7 +33,7 @@ using IsAtLeastForwardIterator = std::is_convertible<
     std::forward_iterator_tag>;
 
 template <typename AllocatorType, typename ValueType, typename SizeType>
-void DestroyElements(AllocatorType alloc, ValueType* destroy_first,
+void DestroyElements(AllocatorType* alloc_ptr, ValueType* destroy_first,
                      SizeType destroy_size) {
   using AllocatorTraits = std::allocator_traits<AllocatorType>;
 
@@ -45,7 +45,7 @@ void DestroyElements(AllocatorType alloc, ValueType* destroy_first,
   // NOTE: We assume destructors do not throw and thus make no attempt to roll
   // back.
   for (SizeType i = 0; i < destroy_size; ++i) {
-    AllocatorTraits::destroy(alloc, destroy_first + i);
+    AllocatorTraits::destroy(*alloc_ptr, destroy_first + i);
   }
 
 #ifndef NDEBUG
@@ -104,10 +104,12 @@ class Storage {
     return data_.allocated.allocated_capacity;
   }
 
-  allocator_type& GetAllocator() { return metadata_.template get<0>(); }
+  allocator_type* GetAllocPtr() {
+    return std::addressof(metadata_.template get<0>());
+  }
 
-  const allocator_type& GetAllocator() const {
-    return metadata_.template get<0>();
+  const allocator_type* GetAllocPtr() const {
+    return std::addressof(metadata_.template get<0>());
   }
 
   void SetAllocatedSize(size_type size) {