30 #ifndef ABSL_CONTAINER_FIXED_ARRAY_H_ 31 #define ABSL_CONTAINER_FIXED_ARRAY_H_ 37 #include <initializer_list> 42 #include <type_traits> 81 typename A = std::allocator<T>>
84 "Arrays with unknown bounds cannot be used with FixedArray.");
91 template <
typename Iterator>
93 typename std::iterator_traits<Iterator>::iterator_category,
110 using pointer =
typename allocator_type::pointer;
122 (N == kFixedArrayUseDefault ? kInlineBytesDefault /
sizeof(
value_type)
123 : static_cast<size_type>(N));
134 std::make_move_iterator(other.
end()),
a) {}
162 template <
typename Iterator, EnableIfForwardIterator<Iterator>* =
nullptr>
191 return (std::numeric_limits<difference_type>::max)() /
sizeof(
value_type);
342 return !(lhs == rhs);
346 return std::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(),
362 template <
typename H>
404 return std::addressof(ptr->
array);
408 static_assert(
alignof(
StorageElement) ==
alignof(value_type),
"");
412 return reinterpret_cast<StorageElement*
>(inlined_storage_.data());
415 #ifdef ADDRESS_SANITIZER 416 void* RedzoneBegin() {
return &redzone_begin_; }
417 void* RedzoneEnd() {
return &redzone_end_ + 1; }
418 #endif // ADDRESS_SANITIZER 449 : size_alloc_(n, a),
data_(InitializeData()) {}
452 if (UsingInlinedStorage(
size())) {
453 InlinedStorage::AnnotateDestruct(
size());
463 return size_alloc_.template get<1>();
472 if (UsingInlinedStorage(
size())) {
473 InlinedStorage::AnnotateConstruct(
size());
477 AllocatorTraits::allocate(
alloc(),
size()));
489 template <
typename T,
size_t N,
typename A>
492 template <
typename T,
size_t N,
typename A>
496 template <
typename T,
size_t N,
typename A>
499 #ifdef ADDRESS_SANITIZER 503 #endif // ADDRESS_SANITIZER 504 static_cast<void>(
n);
507 template <
typename T,
size_t N,
typename A>
510 #ifdef ADDRESS_SANITIZER 514 #endif // ADDRESS_SANITIZER 515 static_cast<void>(
n);
519 #endif // ABSL_CONTAINER_FIXED_ARRAY_H_
std::reverse_iterator< iterator > reverse_iterator
static constexpr size_type inline_elements
StorageElement * InitializeData()
absl::conditional_t< inline_elements==0, EmptyInlinedStorage, NonEmptyInlinedStorage > InlinedStorage
const_iterator end() const
FixedArray(std::initializer_list< value_type > init_list, const allocator_type &a=allocator_type())
const_reference operator[](size_type i) const
const_iterator begin() const
std::reverse_iterator< const_iterator > const_reverse_iterator
void AnnotateDestruct(size_type)
static pointer AsValueType(pointer ptr)
typename std::aligned_storage< Len, Align >::type aligned_storage_t
reverse_iterator rbegin()
StorageElement * end() const
void ThrowStdOutOfRange(const std::string &what_arg)
friend bool operator<=(const FixedArray &lhs, const FixedArray &rhs)
typename std::remove_extent< T >::type remove_extent_t
std::allocator_traits< A > AllocatorTraits
Storage(size_type n, const allocator_type &a)
#define ABSL_PREDICT_FALSE(x)
FixedArray(size_type n, const value_type &val, const allocator_type &a=allocator_type())
constexpr size_type max_size() const
typename allocator_type::const_pointer const_pointer
const_iterator cbegin() const
void fill(const value_type &val)
typename AllocatorTraits::allocator_type allocator_type
typename allocator_type::pointer pointer
reference operator[](size_type i)
typename allocator_type::size_type size_type
container_internal::CompressedTuple< size_type, allocator_type > size_alloc_
static constexpr auto kFixedArrayUseDefault
typename allocator_type::difference_type difference_type
const_iterator cend() const
static bool UsingInlinedStorage(size_type n)
FixedArray(const FixedArray &other, const allocator_type &a=allocator_type()) noexcept(NoexceptCopyable())
friend bool operator==(const FixedArray &lhs, const FixedArray &rhs)
typename std::conditional< B, T, F >::type conditional_t
reference at(size_type i)
typename allocator_type::value_type value_type
typename std::enable_if< B, T >::type enable_if_t
void operator=(FixedArray &&)=delete
static constexpr bool DefaultConstructorIsNonTrivial()
FixedArray(FixedArray &&other, const allocator_type &a=allocator_type()) noexcept(NoexceptMovable())
static std::function< void(void *, Slot *)> destroy
typename allocator_type::reference reference
StorageElement * begin() const
FixedArray(Iterator first, Iterator last, const allocator_type &a=allocator_type())
void AnnotateConstruct(size_type)
void CopyRange(Allocator &alloc, Iterator destination, InputIterator first, InputIterator last)
friend H AbslHashValue(H h, const FixedArray &v)
static char data[kDataSize]
static constexpr size_t kInlineBytesDefault
static constexpr bool NoexceptCopyable()
bool equal(InputIter1 first1, InputIter1 last1, InputIter2 first2, InputIter2 last2, Pred &&pred)
const_reference back() const
friend bool operator!=(const FixedArray &lhs, const FixedArray &rhs)
const_reference front() const
const_reverse_iterator crend() const
void ConstructRange(Allocator &alloc, Iterator first, Iterator last, const Args &...args)
absl::aligned_storage_t< sizeof(StorageElement), alignof(StorageElement)> StorageElementBuffer
std::array< StorageElementBuffer, inline_elements > inlined_storage_
friend bool operator<(const FixedArray &lhs, const FixedArray &rhs)
friend bool operator>=(const FixedArray &lhs, const FixedArray &rhs)
void AnnotateConstruct(size_type)
static constexpr bool NoexceptMovable()
absl::conditional_t< std::is_array< value_type >::value, StorageElementWrapper< value_type >, value_type > StorageElement
std::allocator< int > alloc
typename allocator_type::const_reference const_reference
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
const_pointer const_iterator
static pointer AsValueType(StorageElementWrapper< value_type > *ptr)
const_reverse_iterator crbegin() const
friend bool operator>(const FixedArray &lhs, const FixedArray &rhs)
const_reverse_iterator rend() const
void AnnotateDestruct(size_type)
const_pointer data() const
absl::enable_if_t< std::is_convertible< typename std::iterator_traits< Iterator >::iterator_category, std::forward_iterator_tag >::value > EnableIfForwardIterator
const_reverse_iterator rbegin() const
const_reference at(size_type i) const
#define ADDRESS_SANITIZER_REDZONE(name)
FixedArray(size_type n, const allocator_type &a=allocator_type())
#define ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid)