18#include <initializer_list>
23#include "pw_assert/assert.h"
24#include "pw_containers/internal/count_and_capacity.h"
25#include "pw_containers/internal/generic_deque.h"
26#include "pw_containers/internal/raw_storage.h"
27#include "pw_toolchain/constexpr_tag.h"
30namespace containers::internal {
33template <
typename T,
typename CountAndCapacityType,
size_t kCapacity>
34class BasicInlineDequeImpl;
38template <
typename ValueType,
40 size_t kCapacity = containers::internal::kGenericSized>
41using BasicInlineDeque = containers::internal::BasicInlineDequeImpl<
43 containers::internal::CountAndCapacity<SizeType>,
63template <
typename T,
size_t kCapacity = containers::
internal::kGenericSized>
66namespace containers::internal {
68template <
typename ValueType,
typename CountAndCapacityType,
size_t kCapacity>
71 BasicInlineDequeImpl<ValueType, CountAndCapacityType, kGenericSized>,
79 using typename Base::const_iterator;
80 using typename Base::const_pointer;
81 using typename Base::const_reference;
82 using typename Base::difference_type;
83 using typename Base::iterator;
84 using typename Base::pointer;
85 using typename Base::reference;
86 using typename Base::size_type;
87 using typename Base::value_type;
107 template <
typename InputIterator,
108 typename = EnableIfInputIterator<InputIterator>>
119 template <
size_t kOtherCapacity>
121 CountAndCapacityType,
122 kOtherCapacity>& other) {
128 *
this = std::move(other);
132 template <
size_t kOtherCapacity>
136 *
this = std::move(other);
145 template <
typename T,
typename = EnableIfIterable<T>>
162 const std::initializer_list<value_type>& list) {
163 Base::operator=(list);
169 Base::operator=(
static_cast<const Base&
>(other));
176 template <
size_t kOtherCapacity>
179 CountAndCapacityType,
180 kOtherCapacity>& other) {
181 Base::operator=(
static_cast<const Base&
>(other));
187 Base::operator=(
static_cast<Base&&
>(std::move(other)));
192 template <
size_t kOtherCapacity>
196 Base::operator=(
static_cast<Base&&
>(std::move(other)));
200 template <
typename T,
typename = EnableIfIterable<T>>
202 Base::operator=(other);
208 static constexpr size_type max_size() {
return capacity(); }
209 static constexpr size_type capacity() {
return kCapacity; }
220template <
typename ValueType,
typename CountAndCapacityType>
223 BasicInlineDequeImpl<ValueType, CountAndCapacityType, kGenericSized>,
225 CountAndCapacityType> {
230 CountAndCapacityType>;
233 using typename Base::const_iterator;
234 using typename Base::const_pointer;
235 using typename Base::const_reference;
236 using typename Base::difference_type;
237 using typename Base::iterator;
238 using typename Base::pointer;
239 using typename Base::reference;
240 using typename Base::size_type;
241 using typename Base::value_type;
253 for (
auto&& item : other) {
254 Base::emplace_back(std::move(item));
260 using Base::operator=;
264 [[nodiscard]]
bool full()
const noexcept {
276 template <
size_t kCapacity>
277 using Derived = RawStorage<
286 pointer data() {
return static_cast<Derived<0>*
>(
this)->data(); }
287 const_pointer data()
const {
288 return static_cast<const Derived<0>*
>(
this)->data();
294 static constexpr bool kFixedCapacity =
true;
Definition: inline_deque.h:225
Definition: inline_deque.h:73
BasicInlineDequeImpl(size_type count)
Constructs with count default-initialized elements.
Definition: inline_deque.h:103
BasicInlineDequeImpl & operator=(BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &&other) noexcept
Move assigns for mismatched capacity.
Definition: inline_deque.h:193
BasicInlineDequeImpl(const BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &other)
Definition: inline_deque.h:120
BasicInlineDequeImpl & operator=(BasicInlineDequeImpl &&other) noexcept
Move assigns for matching capacity.
Definition: inline_deque.h:186
BasicInlineDequeImpl & operator=(const BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &other)
Definition: inline_deque.h:177
BasicInlineDequeImpl & operator=(const std::initializer_list< value_type > &list)
Copy assigns from list.
Definition: inline_deque.h:161
BasicInlineDequeImpl() noexcept
Constructs with zero elements.
Definition: inline_deque.h:90
BasicInlineDequeImpl(BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &&other) noexcept
Move constructs for mismatched capacity.
Definition: inline_deque.h:133
BasicInlineDequeImpl(BasicInlineDequeImpl &&other) noexcept
Move constructs for matching capacity.
Definition: inline_deque.h:127
BasicInlineDequeImpl(const std::initializer_list< value_type > &list)
Copy constructs from an initializer list.
Definition: inline_deque.h:140
BasicInlineDequeImpl & operator=(const BasicInlineDequeImpl &other)
Copy assigns for matching capacity.
Definition: inline_deque.h:168
BasicInlineDequeImpl(const BasicInlineDequeImpl &other)
Copy constructs for matching capacity.
Definition: inline_deque.h:114
BasicInlineDequeImpl(size_type count, const_reference value)
Constructs with count copies of value.
Definition: inline_deque.h:98
BasicInlineDequeImpl(const T &other)
Copy constructor for arbitrary iterables.
Definition: inline_deque.h:146
BasicInlineDequeImpl(InputIterator start, InputIterator finish)
Copy constructs from an iterator.
Definition: inline_deque.h:109
constexpr size_type size() const noexcept
Returns the number of elements in the deque.
Definition: generic_deque.h:58
constexpr size_type capacity() const noexcept
Returns the maximum number of elements in the deque.
Definition: generic_deque.h:63
Definition: generic_deque.h:189
void assign(size_type count, const value_type &value)
Sets the contents to count copies of value. Crashes if cannot fit.
Definition: generic_deque.h:220
Provides basic helpers for reading and writing UTF-8 encoded strings.
Definition: alignment.h:27
Definition: constexpr_tag.h:46