fixed_array.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. // Copyright 2018 The Abseil Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // -----------------------------------------------------------------------------
  16. // File: fixed_array.h
  17. // -----------------------------------------------------------------------------
  18. //
  19. // A `FixedArray<T>` represents a non-resizable array of `T` where the length of
  20. // the array can be determined at run-time. It is a good replacement for
  21. // non-standard and deprecated uses of `alloca()` and variable length arrays
  22. // within the GCC extension. (See
  23. // https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html).
  24. //
  25. // `FixedArray` allocates small arrays inline, keeping performance fast by
  26. // avoiding heap operations. It also helps reduce the chances of
  27. // accidentally overflowing your stack if large input is passed to
  28. // your function.
  29. #ifndef Y_ABSL_CONTAINER_FIXED_ARRAY_H_
  30. #define Y_ABSL_CONTAINER_FIXED_ARRAY_H_
  31. #include <algorithm>
  32. #include <cassert>
  33. #include <cstddef>
  34. #include <initializer_list>
  35. #include <iterator>
  36. #include <limits>
  37. #include <memory>
  38. #include <new>
  39. #include <type_traits>
  40. #include "y_absl/algorithm/algorithm.h"
  41. #include "y_absl/base/config.h"
  42. #include "y_absl/base/dynamic_annotations.h"
  43. #include "y_absl/base/internal/throw_delegate.h"
  44. #include "y_absl/base/macros.h"
  45. #include "y_absl/base/optimization.h"
  46. #include "y_absl/base/port.h"
  47. #include "y_absl/container/internal/compressed_tuple.h"
  48. #include "y_absl/memory/memory.h"
  49. namespace y_absl {
  50. Y_ABSL_NAMESPACE_BEGIN
  51. constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1);
  52. // -----------------------------------------------------------------------------
  53. // FixedArray
  54. // -----------------------------------------------------------------------------
  55. //
  56. // A `FixedArray` provides a run-time fixed-size array, allocating a small array
  57. // inline for efficiency.
  58. //
  59. // Most users should not specify the `N` template parameter and let `FixedArray`
  60. // automatically determine the number of elements to store inline based on
  61. // `sizeof(T)`. If `N` is specified, the `FixedArray` implementation will use
  62. // inline storage for arrays with a length <= `N`.
  63. //
  64. // Note that a `FixedArray` constructed with a `size_type` argument will
  65. // default-initialize its values by leaving trivially constructible types
  66. // uninitialized (e.g. int, int[4], double), and others default-constructed.
  67. // This matches the behavior of c-style arrays and `std::array`, but not
  68. // `std::vector`.
  69. template <typename T, size_t N = kFixedArrayUseDefault,
  70. typename A = std::allocator<T>>
  71. class FixedArray {
  72. static_assert(!std::is_array<T>::value || std::extent<T>::value > 0,
  73. "Arrays with unknown bounds cannot be used with FixedArray.");
  74. static constexpr size_t kInlineBytesDefault = 256;
  75. using AllocatorTraits = std::allocator_traits<A>;
  76. // std::iterator_traits isn't guaranteed to be SFINAE-friendly until C++17,
  77. // but this seems to be mostly pedantic.
  78. template <typename Iterator>
  79. using EnableIfForwardIterator = y_absl::enable_if_t<std::is_convertible<
  80. typename std::iterator_traits<Iterator>::iterator_category,
  81. std::forward_iterator_tag>::value>;
  82. static constexpr bool NoexceptCopyable() {
  83. return std::is_nothrow_copy_constructible<StorageElement>::value &&
  84. y_absl::allocator_is_nothrow<allocator_type>::value;
  85. }
  86. static constexpr bool NoexceptMovable() {
  87. return std::is_nothrow_move_constructible<StorageElement>::value &&
  88. y_absl::allocator_is_nothrow<allocator_type>::value;
  89. }
  90. static constexpr bool DefaultConstructorIsNonTrivial() {
  91. return !y_absl::is_trivially_default_constructible<StorageElement>::value;
  92. }
  93. public:
  94. using allocator_type = typename AllocatorTraits::allocator_type;
  95. using value_type = typename AllocatorTraits::value_type;
  96. using pointer = typename AllocatorTraits::pointer;
  97. using const_pointer = typename AllocatorTraits::const_pointer;
  98. using reference = value_type&;
  99. using const_reference = const value_type&;
  100. using size_type = typename AllocatorTraits::size_type;
  101. using difference_type = typename AllocatorTraits::difference_type;
  102. using iterator = pointer;
  103. using const_iterator = const_pointer;
  104. using reverse_iterator = std::reverse_iterator<iterator>;
  105. using const_reverse_iterator = std::reverse_iterator<const_iterator>;
  106. static constexpr size_type inline_elements =
  107. (N == kFixedArrayUseDefault ? kInlineBytesDefault / sizeof(value_type)
  108. : static_cast<size_type>(N));
  109. FixedArray(const FixedArray& other) noexcept(NoexceptCopyable())
  110. : FixedArray(other,
  111. AllocatorTraits::select_on_container_copy_construction(
  112. other.storage_.alloc())) {}
  113. FixedArray(const FixedArray& other,
  114. const allocator_type& a) noexcept(NoexceptCopyable())
  115. : FixedArray(other.begin(), other.end(), a) {}
  116. FixedArray(FixedArray&& other) noexcept(NoexceptMovable())
  117. : FixedArray(std::move(other), other.storage_.alloc()) {}
  118. FixedArray(FixedArray&& other,
  119. const allocator_type& a) noexcept(NoexceptMovable())
  120. : FixedArray(std::make_move_iterator(other.begin()),
  121. std::make_move_iterator(other.end()), a) {}
  122. // Creates an array object that can store `n` elements.
  123. // Note that trivially constructible elements will be uninitialized.
  124. explicit FixedArray(size_type n, const allocator_type& a = allocator_type())
  125. : storage_(n, a) {
  126. if (DefaultConstructorIsNonTrivial()) {
  127. memory_internal::ConstructRange(storage_.alloc(), storage_.begin(),
  128. storage_.end());
  129. }
  130. }
  131. // Creates an array initialized with `n` copies of `val`.
  132. FixedArray(size_type n, const value_type& val,
  133. const allocator_type& a = allocator_type())
  134. : storage_(n, a) {
  135. memory_internal::ConstructRange(storage_.alloc(), storage_.begin(),
  136. storage_.end(), val);
  137. }
  138. // Creates an array initialized with the size and contents of `init_list`.
  139. FixedArray(std::initializer_list<value_type> init_list,
  140. const allocator_type& a = allocator_type())
  141. : FixedArray(init_list.begin(), init_list.end(), a) {}
  142. // Creates an array initialized with the elements from the input
  143. // range. The array's size will always be `std::distance(first, last)`.
  144. // REQUIRES: Iterator must be a forward_iterator or better.
  145. template <typename Iterator, EnableIfForwardIterator<Iterator>* = nullptr>
  146. FixedArray(Iterator first, Iterator last,
  147. const allocator_type& a = allocator_type())
  148. : storage_(std::distance(first, last), a) {
  149. memory_internal::CopyRange(storage_.alloc(), storage_.begin(), first, last);
  150. }
  151. ~FixedArray() noexcept {
  152. for (auto* cur = storage_.begin(); cur != storage_.end(); ++cur) {
  153. AllocatorTraits::destroy(storage_.alloc(), cur);
  154. }
  155. }
  156. // Assignments are deleted because they break the invariant that the size of a
  157. // `FixedArray` never changes.
  158. void operator=(FixedArray&&) = delete;
  159. void operator=(const FixedArray&) = delete;
  160. // FixedArray::size()
  161. //
  162. // Returns the length of the fixed array.
  163. size_type size() const { return storage_.size(); }
  164. // FixedArray::max_size()
  165. //
  166. // Returns the largest possible value of `std::distance(begin(), end())` for a
  167. // `FixedArray<T>`. This is equivalent to the most possible addressable bytes
  168. // over the number of bytes taken by T.
  169. constexpr size_type max_size() const {
  170. return (std::numeric_limits<difference_type>::max)() / sizeof(value_type);
  171. }
  172. // FixedArray::empty()
  173. //
  174. // Returns whether or not the fixed array is empty.
  175. bool empty() const { return size() == 0; }
  176. // FixedArray::memsize()
  177. //
  178. // Returns the memory size of the fixed array in bytes.
  179. size_t memsize() const { return size() * sizeof(value_type); }
  180. // FixedArray::data()
  181. //
  182. // Returns a const T* pointer to elements of the `FixedArray`. This pointer
  183. // can be used to access (but not modify) the contained elements.
  184. const_pointer data() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  185. return AsValueType(storage_.begin());
  186. }
  187. // Overload of FixedArray::data() to return a T* pointer to elements of the
  188. // fixed array. This pointer can be used to access and modify the contained
  189. // elements.
  190. pointer data() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  191. return AsValueType(storage_.begin());
  192. }
  193. // FixedArray::operator[]
  194. //
  195. // Returns a reference the ith element of the fixed array.
  196. // REQUIRES: 0 <= i < size()
  197. reference operator[](size_type i) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  198. Y_ABSL_HARDENING_ASSERT(i < size());
  199. return data()[i];
  200. }
  201. // Overload of FixedArray::operator()[] to return a const reference to the
  202. // ith element of the fixed array.
  203. // REQUIRES: 0 <= i < size()
  204. const_reference operator[](size_type i) const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  205. Y_ABSL_HARDENING_ASSERT(i < size());
  206. return data()[i];
  207. }
  208. // FixedArray::at
  209. //
  210. // Bounds-checked access. Returns a reference to the ith element of the fixed
  211. // array, or throws std::out_of_range
  212. reference at(size_type i) Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  213. if (Y_ABSL_PREDICT_FALSE(i >= size())) {
  214. base_internal::ThrowStdOutOfRange("FixedArray::at failed bounds check");
  215. }
  216. return data()[i];
  217. }
  218. // Overload of FixedArray::at() to return a const reference to the ith element
  219. // of the fixed array.
  220. const_reference at(size_type i) const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  221. if (Y_ABSL_PREDICT_FALSE(i >= size())) {
  222. base_internal::ThrowStdOutOfRange("FixedArray::at failed bounds check");
  223. }
  224. return data()[i];
  225. }
  226. // FixedArray::front()
  227. //
  228. // Returns a reference to the first element of the fixed array.
  229. reference front() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  230. Y_ABSL_HARDENING_ASSERT(!empty());
  231. return data()[0];
  232. }
  233. // Overload of FixedArray::front() to return a reference to the first element
  234. // of a fixed array of const values.
  235. const_reference front() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  236. Y_ABSL_HARDENING_ASSERT(!empty());
  237. return data()[0];
  238. }
  239. // FixedArray::back()
  240. //
  241. // Returns a reference to the last element of the fixed array.
  242. reference back() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  243. Y_ABSL_HARDENING_ASSERT(!empty());
  244. return data()[size() - 1];
  245. }
  246. // Overload of FixedArray::back() to return a reference to the last element
  247. // of a fixed array of const values.
  248. const_reference back() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  249. Y_ABSL_HARDENING_ASSERT(!empty());
  250. return data()[size() - 1];
  251. }
  252. // FixedArray::begin()
  253. //
  254. // Returns an iterator to the beginning of the fixed array.
  255. iterator begin() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return data(); }
  256. // Overload of FixedArray::begin() to return a const iterator to the
  257. // beginning of the fixed array.
  258. const_iterator begin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return data(); }
  259. // FixedArray::cbegin()
  260. //
  261. // Returns a const iterator to the beginning of the fixed array.
  262. const_iterator cbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  263. return begin();
  264. }
  265. // FixedArray::end()
  266. //
  267. // Returns an iterator to the end of the fixed array.
  268. iterator end() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return data() + size(); }
  269. // Overload of FixedArray::end() to return a const iterator to the end of the
  270. // fixed array.
  271. const_iterator end() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  272. return data() + size();
  273. }
  274. // FixedArray::cend()
  275. //
  276. // Returns a const iterator to the end of the fixed array.
  277. const_iterator cend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND { return end(); }
  278. // FixedArray::rbegin()
  279. //
  280. // Returns a reverse iterator from the end of the fixed array.
  281. reverse_iterator rbegin() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  282. return reverse_iterator(end());
  283. }
  284. // Overload of FixedArray::rbegin() to return a const reverse iterator from
  285. // the end of the fixed array.
  286. const_reverse_iterator rbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  287. return const_reverse_iterator(end());
  288. }
  289. // FixedArray::crbegin()
  290. //
  291. // Returns a const reverse iterator from the end of the fixed array.
  292. const_reverse_iterator crbegin() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  293. return rbegin();
  294. }
  295. // FixedArray::rend()
  296. //
  297. // Returns a reverse iterator from the beginning of the fixed array.
  298. reverse_iterator rend() Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  299. return reverse_iterator(begin());
  300. }
  301. // Overload of FixedArray::rend() for returning a const reverse iterator
  302. // from the beginning of the fixed array.
  303. const_reverse_iterator rend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  304. return const_reverse_iterator(begin());
  305. }
  306. // FixedArray::crend()
  307. //
  308. // Returns a reverse iterator from the beginning of the fixed array.
  309. const_reverse_iterator crend() const Y_ABSL_ATTRIBUTE_LIFETIME_BOUND {
  310. return rend();
  311. }
  312. // FixedArray::fill()
  313. //
  314. // Assigns the given `value` to all elements in the fixed array.
  315. void fill(const value_type& val) { std::fill(begin(), end(), val); }
  316. // Relational operators. Equality operators are elementwise using
  317. // `operator==`, while order operators order FixedArrays lexicographically.
  318. friend bool operator==(const FixedArray& lhs, const FixedArray& rhs) {
  319. return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
  320. }
  321. friend bool operator!=(const FixedArray& lhs, const FixedArray& rhs) {
  322. return !(lhs == rhs);
  323. }
  324. friend bool operator<(const FixedArray& lhs, const FixedArray& rhs) {
  325. return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(),
  326. rhs.end());
  327. }
  328. friend bool operator>(const FixedArray& lhs, const FixedArray& rhs) {
  329. return rhs < lhs;
  330. }
  331. friend bool operator<=(const FixedArray& lhs, const FixedArray& rhs) {
  332. return !(rhs < lhs);
  333. }
  334. friend bool operator>=(const FixedArray& lhs, const FixedArray& rhs) {
  335. return !(lhs < rhs);
  336. }
  337. template <typename H>
  338. friend H AbslHashValue(H h, const FixedArray& v) {
  339. return H::combine(H::combine_contiguous(std::move(h), v.data(), v.size()),
  340. v.size());
  341. }
  342. private:
  343. // StorageElement
  344. //
  345. // For FixedArrays with a C-style-array value_type, StorageElement is a POD
  346. // wrapper struct called StorageElementWrapper that holds the value_type
  347. // instance inside. This is needed for construction and destruction of the
  348. // entire array regardless of how many dimensions it has. For all other cases,
  349. // StorageElement is just an alias of value_type.
  350. //
  351. // Maintainer's Note: The simpler solution would be to simply wrap value_type
  352. // in a struct whether it's an array or not. That causes some paranoid
  353. // diagnostics to misfire, believing that 'data()' returns a pointer to a
  354. // single element, rather than the packed array that it really is.
  355. // e.g.:
  356. //
  357. // FixedArray<char> buf(1);
  358. // sprintf(buf.data(), "foo");
  359. //
  360. // error: call to int __builtin___sprintf_chk(etc...)
  361. // will always overflow destination buffer [-Werror]
  362. //
  363. template <typename OuterT, typename InnerT = y_absl::remove_extent_t<OuterT>,
  364. size_t InnerN = std::extent<OuterT>::value>
  365. struct StorageElementWrapper {
  366. InnerT array[InnerN];
  367. };
  368. using StorageElement =
  369. y_absl::conditional_t<std::is_array<value_type>::value,
  370. StorageElementWrapper<value_type>, value_type>;
  371. static pointer AsValueType(pointer ptr) { return ptr; }
  372. static pointer AsValueType(StorageElementWrapper<value_type>* ptr) {
  373. return std::addressof(ptr->array);
  374. }
  375. static_assert(sizeof(StorageElement) == sizeof(value_type), "");
  376. static_assert(alignof(StorageElement) == alignof(value_type), "");
  377. class NonEmptyInlinedStorage {
  378. public:
  379. StorageElement* data() { return reinterpret_cast<StorageElement*>(buff_); }
  380. void AnnotateConstruct(size_type n);
  381. void AnnotateDestruct(size_type n);
  382. #ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
  383. void* RedzoneBegin() { return &redzone_begin_; }
  384. void* RedzoneEnd() { return &redzone_end_ + 1; }
  385. #endif // Y_ABSL_HAVE_ADDRESS_SANITIZER
  386. private:
  387. Y_ABSL_ADDRESS_SANITIZER_REDZONE(redzone_begin_);
  388. alignas(StorageElement) char buff_[sizeof(StorageElement[inline_elements])];
  389. Y_ABSL_ADDRESS_SANITIZER_REDZONE(redzone_end_);
  390. };
  391. class EmptyInlinedStorage {
  392. public:
  393. StorageElement* data() { return nullptr; }
  394. void AnnotateConstruct(size_type) {}
  395. void AnnotateDestruct(size_type) {}
  396. };
  397. using InlinedStorage =
  398. y_absl::conditional_t<inline_elements == 0, EmptyInlinedStorage,
  399. NonEmptyInlinedStorage>;
  400. // Storage
  401. //
  402. // An instance of Storage manages the inline and out-of-line memory for
  403. // instances of FixedArray. This guarantees that even when construction of
  404. // individual elements fails in the FixedArray constructor body, the
  405. // destructor for Storage will still be called and out-of-line memory will be
  406. // properly deallocated.
  407. //
  408. class Storage : public InlinedStorage {
  409. public:
  410. Storage(size_type n, const allocator_type& a)
  411. : size_alloc_(n, a), data_(InitializeData()) {}
  412. ~Storage() noexcept {
  413. if (UsingInlinedStorage(size())) {
  414. InlinedStorage::AnnotateDestruct(size());
  415. } else {
  416. AllocatorTraits::deallocate(alloc(), AsValueType(begin()), size());
  417. }
  418. }
  419. size_type size() const { return size_alloc_.template get<0>(); }
  420. StorageElement* begin() const { return data_; }
  421. StorageElement* end() const { return begin() + size(); }
  422. allocator_type& alloc() { return size_alloc_.template get<1>(); }
  423. const allocator_type& alloc() const {
  424. return size_alloc_.template get<1>();
  425. }
  426. private:
  427. static bool UsingInlinedStorage(size_type n) {
  428. return n <= inline_elements;
  429. }
  430. #ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
  431. Y_ABSL_ATTRIBUTE_NOINLINE
  432. #endif // Y_ABSL_HAVE_ADDRESS_SANITIZER
  433. StorageElement* InitializeData() {
  434. if (UsingInlinedStorage(size())) {
  435. InlinedStorage::AnnotateConstruct(size());
  436. return InlinedStorage::data();
  437. } else {
  438. return reinterpret_cast<StorageElement*>(
  439. AllocatorTraits::allocate(alloc(), size()));
  440. }
  441. }
  442. // `CompressedTuple` takes advantage of EBCO for stateless `allocator_type`s
  443. container_internal::CompressedTuple<size_type, allocator_type> size_alloc_;
  444. StorageElement* data_;
  445. };
  446. Storage storage_;
  447. };
  448. #ifdef Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
  449. template <typename T, size_t N, typename A>
  450. constexpr size_t FixedArray<T, N, A>::kInlineBytesDefault;
  451. template <typename T, size_t N, typename A>
  452. constexpr typename FixedArray<T, N, A>::size_type
  453. FixedArray<T, N, A>::inline_elements;
  454. #endif
  455. template <typename T, size_t N, typename A>
  456. void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateConstruct(
  457. typename FixedArray<T, N, A>::size_type n) {
  458. #ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
  459. if (!n) return;
  460. Y_ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), RedzoneEnd(),
  461. data() + n);
  462. Y_ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), data(),
  463. RedzoneBegin());
  464. #endif // Y_ABSL_HAVE_ADDRESS_SANITIZER
  465. static_cast<void>(n); // Mark used when not in asan mode
  466. }
  467. template <typename T, size_t N, typename A>
  468. void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateDestruct(
  469. typename FixedArray<T, N, A>::size_type n) {
  470. #ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
  471. if (!n) return;
  472. Y_ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(data(), RedzoneEnd(), data() + n,
  473. RedzoneEnd());
  474. Y_ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(RedzoneBegin(), data(), RedzoneBegin(),
  475. data());
  476. #endif // Y_ABSL_HAVE_ADDRESS_SANITIZER
  477. static_cast<void>(n); // Mark used when not in asan mode
  478. }
  479. Y_ABSL_NAMESPACE_END
  480. } // namespace y_absl
  481. #endif // Y_ABSL_CONTAINER_FIXED_ARRAY_H_