41 FixedArray(FixedArray&& other)
noexcept;
42 FixedArray& operator=(FixedArray&& other)
noexcept;
44 FixedArray(
const FixedArray&) =
delete;
45 FixedArray& operator=(
const FixedArray&) =
delete;
49 std::size_t size()
const noexcept {
return size_; }
50 bool empty()
const noexcept {
return size_ == 0; }
52 const T& operator[](std::size_t i)
const noexcept USERVER_IMPL_LIFETIME_BOUND {
57 T& operator[](std::size_t i)
noexcept USERVER_IMPL_LIFETIME_BOUND {
62 T& front()
noexcept USERVER_IMPL_LIFETIME_BOUND {
return *NonEmptyData(); }
63 const T& front()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return *NonEmptyData(); }
65 T& back()
noexcept USERVER_IMPL_LIFETIME_BOUND {
return *(NonEmptyData() + size_ - 1); }
66 const T& back()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return *(NonEmptyData() + size_ - 1); }
68 T* data()
noexcept USERVER_IMPL_LIFETIME_BOUND {
return storage_; }
69 const T* data()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return storage_; }
71 T* begin()
noexcept USERVER_IMPL_LIFETIME_BOUND {
return data(); }
72 T* end()
noexcept USERVER_IMPL_LIFETIME_BOUND {
return data() + size_; }
73 const T* begin()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return data(); }
74 const T* end()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return data() + size_; }
75 const T* cbegin()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return data(); }
76 const T* cend()
const noexcept USERVER_IMPL_LIFETIME_BOUND {
return data() + size_; }
79 template <
class GeneratorFunc>
80 FixedArray(impl::InternalTag tag, std::size_t size, GeneratorFunc&& generator);
84 T* NonEmptyData()
noexcept {
89 const T* NonEmptyData()
const noexcept {
108template <
class GeneratorFunc>
112template <
class... Args>
119 storage_ = std::allocator<T>{}.allocate(size_);
121 auto* begin = data();
123 for (
auto* end = begin + size - 1; begin != end; ++begin) {
124 new (begin) T(args...);
126 new (begin) T(std::forward<Args>(args)...);
128 std::destroy(data(), begin);
129 std::allocator<T>{}.deallocate(storage_, size);
162 : storage_(std::exchange(other.storage_,
nullptr)), size_(std::exchange(other.size_, 0)) {}
179 using ResultType = std::remove_reference_t<std::invoke_result_t<GeneratorFunc&, std::size_t>>;
180 return FixedArray<ResultType>(impl::InternalTag{}, size, std::forward<GeneratorFunc>(generator));