@ -155,7 +155,7 @@ class InlinedVector {
// Creates a copy of an `other` inlined vector using `other`'s allocator.
InlinedVector ( const InlinedVector & other )
: InlinedVector ( other , other . storage_ . GetAllocato r ( ) ) { }
: InlinedVector ( other , * other . storage_ . GetAllocPt r ( ) ) { }
// Creates a copy of an `other` inlined vector using a specified allocator.
InlinedVector ( const InlinedVector & other , const allocator_type & alloc )
@ -189,7 +189,7 @@ class InlinedVector {
InlinedVector ( InlinedVector & & other ) noexcept (
absl : : allocator_is_nothrow < allocator_type > : : value | |
std : : is_nothrow_move_constructible < value_type > : : value )
: storage_ ( other . storage_ . GetAllocato r ( ) ) {
: storage_ ( * other . storage_ . GetAllocPt r ( ) ) {
if ( other . storage_ . GetIsAllocated ( ) ) {
// We can just steal the underlying buffer from the source.
// That leaves the source empty, so we clear its size.
@ -224,7 +224,7 @@ class InlinedVector {
absl : : allocator_is_nothrow < allocator_type > : : value )
: storage_ ( alloc ) {
if ( other . storage_ . GetIsAllocated ( ) ) {
if ( alloc = = other . storage_ . GetAllocato r ( ) ) {
if ( * stor age_ . GetA llocPtr ( ) = = * other . storage_ . GetAllocPt r ( ) ) {
// We can just steal the allocation from the source.
storage_ . SetAllocatedSize ( other . size ( ) ) ;
storage_ . SetAllocatedData ( other . storage_ . GetAllocatedData ( ) ) ;
@ -437,7 +437,7 @@ class InlinedVector {
// `InlinedVector::get_allocator()`
//
// Returns a copy of the allocator of the inlined vector.
allocator_type get_allocator ( ) const { return storage_ . GetAllocato r ( ) ; }
allocator_type get_allocator ( ) const { return * storage_ . GetAllocPt r ( ) ; }
// ---------------------------------------------------------------------------
// InlinedVector Member Mutators
@ -794,19 +794,15 @@ class InlinedVector {
// deallocates the heap allocation if the inlined vector was allocated.
void clear ( ) noexcept {
const bool is_allocated = storage_ . GetIsAllocated ( ) ;
pointer the_data =
is_allocated ? storage_ . GetAllocatedData ( ) : storage_ . GetInlinedData ( ) ;
inlined_vector_internal : : DestroyElements ( storage_ . GetAllocator ( ) , the_data ,
inlined_vector_internal : : DestroyElements ( storage_ . GetAllocPtr ( ) , the_data ,
storage_ . GetSize ( ) ) ;
storage_ . SetInlinedSize ( 0 ) ;
if ( is_allocated ) {
AllocatorTraits : : deallocate ( storage_ . GetAllocato r ( ) , the_data ,
AllocatorTraits : : deallocate ( * storage_ . GetAllocPt r ( ) , the_data ,
storage_ . GetAllocatedCapacity ( ) ) ;
}
storage_ . SetInlinedSize ( /* size = */ 0 ) ;
}
// `InlinedVector::reserve()`
@ -854,7 +850,7 @@ class InlinedVector {
// Reallocate storage and move elements.
// We can't simply use the same approach as above, because `assign()` would
// call into `reserve()` internally and reserve larger capacity than we need
pointer new_data = AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , s ) ;
pointer new_data = AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , s ) ;
UninitializedCopy ( std : : make_move_iterator ( storage_ . GetAllocatedData ( ) ) ,
std : : make_move_iterator ( storage_ . GetAllocatedData ( ) + s ) ,
new_data ) ;
@ -880,7 +876,7 @@ class InlinedVector {
Destroy ( storage_ . GetAllocatedData ( ) ,
storage_ . GetAllocatedData ( ) + size ( ) ) ;
assert ( begin ( ) = = storage_ . GetAllocatedData ( ) ) ;
AllocatorTraits : : deallocate ( storage_ . GetAllocato r ( ) ,
AllocatorTraits : : deallocate ( * storage_ . GetAllocPt r ( ) ,
storage_ . GetAllocatedData ( ) ,
storage_ . GetAllocatedCapacity ( ) ) ;
} else {
@ -895,7 +891,7 @@ class InlinedVector {
template < typename . . . Args >
reference Construct ( pointer p , Args & & . . . args ) {
std : : allocator_traits < allocator_type > : : construct (
storage_ . GetAllocato r ( ) , p , std : : forward < Args > ( args ) . . . ) ;
* storage_ . GetAllocPt r ( ) , p , std : : forward < Args > ( args ) . . . ) ;
return * p ;
}
@ -912,7 +908,7 @@ class InlinedVector {
// Destroy [`from`, `to`) in place.
void Destroy ( pointer from , pointer to ) {
for ( pointer cur = from ; cur ! = to ; + + cur ) {
std : : allocator_traits < allocator_type > : : destroy ( storage_ . GetAllocato r ( ) ,
std : : allocator_traits < allocator_type > : : destroy ( * storage_ . GetAllocPt r ( ) ,
cur ) ;
}
# if !defined(NDEBUG)
@ -943,7 +939,7 @@ class InlinedVector {
}
pointer new_data =
AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , new_capacity ) ;
AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , new_capacity ) ;
UninitializedCopy ( std : : make_move_iterator ( data ( ) ) ,
std : : make_move_iterator ( data ( ) + s ) , new_data ) ;
@ -975,7 +971,7 @@ class InlinedVector {
// Move everyone into the new allocation, leaving a gap of `n` for the
// requested shift.
pointer new_data =
AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , new_capacity ) ;
AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , new_capacity ) ;
size_type index = position - begin ( ) ;
UninitializedCopy ( std : : make_move_iterator ( data ( ) ) ,
std : : make_move_iterator ( data ( ) + index ) , new_data ) ;
@ -1024,7 +1020,7 @@ class InlinedVector {
size_type new_capacity = 2 * capacity ( ) ;
pointer new_data =
AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , new_capacity ) ;
AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , new_capacity ) ;
reference new_element =
Construct ( new_data + s , std : : forward < Args > ( args ) . . . ) ;
@ -1038,7 +1034,7 @@ class InlinedVector {
void InitAssign ( size_type n ) {
if ( n > static_cast < size_type > ( N ) ) {
pointer new_data = AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , n ) ;
pointer new_data = AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , n ) ;
storage_ . SetAllocatedData ( new_data ) ;
storage_ . SetAllocatedCapacity ( n ) ;
UninitializedFill ( storage_ . GetAllocatedData ( ) ,
@ -1053,7 +1049,7 @@ class InlinedVector {
void InitAssign ( size_type n , const_reference v ) {
if ( n > static_cast < size_type > ( N ) ) {
pointer new_data = AllocatorTraits : : allocate ( storage_ . GetAllocato r ( ) , n ) ;
pointer new_data = AllocatorTraits : : allocate ( * storage_ . GetAllocPt r ( ) , n ) ;
storage_ . SetAllocatedData ( new_data ) ;
storage_ . SetAllocatedCapacity ( n ) ;
UninitializedFill ( storage_ . GetAllocatedData ( ) ,
@ -1126,7 +1122,7 @@ class InlinedVector {
// Both out of line, so just swap the tag, allocation, and allocator.
storage_ . SwapSizeAndIsAllocated ( std : : addressof ( other . storage_ ) ) ;
storage_ . SwapAllocatedSizeAndCapacity ( std : : addressof ( other . storage_ ) ) ;
swap ( storage_ . GetAllocato r ( ) , other . storage_ . GetAllocato r ( ) ) ;
swap ( * storage_ . GetAllocPt r ( ) , * other . storage_ . GetAllocPt r ( ) ) ;
return ;
}
@ -1156,7 +1152,7 @@ class InlinedVector {
a - > storage_ . GetInlinedData ( ) + a_size ) ;
storage_ . SwapSizeAndIsAllocated ( std : : addressof ( other . storage_ ) ) ;
swap ( storage_ . GetAllocato r ( ) , other . storage_ . GetAllocato r ( ) ) ;
swap ( * storage_ . GetAllocPt r ( ) , * other . storage_ . GetAllocPt r ( ) ) ;
assert ( b - > size ( ) = = a_size ) ;
assert ( a - > size ( ) = = b_size ) ;
@ -1198,8 +1194,8 @@ class InlinedVector {
a - > storage_ . SetAllocatedData ( b_data ) ;
a - > storage_ . SetAllocatedCapacity ( b_capacity ) ;
if ( a - > storage_ . GetAllocato r ( ) ! = b - > storage_ . GetAllocato r ( ) ) {
swap ( a - > storage_ . GetAllocato r ( ) , b - > storage_ . GetAllocato r ( ) ) ;
if ( * a - > storage_ . GetAllocPt r ( ) ! = * b - > storage_ . GetAllocPt r ( ) ) {
swap ( * a - > storage_ . GetAllocPt r ( ) , * b - > storage_ . GetAllocPt r ( ) ) ;
}
assert ( b - > size ( ) = = a_size ) ;