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;
40template <
typename ValueType,
42 size_t kCapacity = containers::internal::kGenericSized>
43using BasicInlineDeque = containers::internal::BasicInlineDequeImpl<
45 containers::internal::CountAndCapacity<SizeType>,
65template <
typename T,
size_t kCapacity = containers::
internal::kGenericSized>
70namespace containers::internal {
72template <
typename ValueType,
typename CountAndCapacityType,
size_t kCapacity>
75 BasicInlineDequeImpl<ValueType, CountAndCapacityType, kGenericSized>,
83 using typename Base::const_iterator;
84 using typename Base::const_pointer;
85 using typename Base::const_reference;
86 using typename Base::difference_type;
87 using typename Base::iterator;
88 using typename Base::pointer;
89 using typename Base::reference;
90 using typename Base::size_type;
91 using typename Base::value_type;
111 template <
typename InputIterator,
112 typename = EnableIfInputIterator<InputIterator>>
123 template <
size_t kOtherCapacity>
125 CountAndCapacityType,
126 kOtherCapacity>& other) {
132 *
this = std::move(other);
136 template <
size_t kOtherCapacity>
140 *
this = std::move(other);
149 template <
typename T,
typename = EnableIfIterable<T>>
166 const std::initializer_list<value_type>& list) {
167 Base::operator=(list);
173 Base::operator=(
static_cast<const Base&
>(other));
180 template <
size_t kOtherCapacity>
183 CountAndCapacityType,
184 kOtherCapacity>& other) {
185 Base::operator=(
static_cast<const Base&
>(other));
191 Base::operator=(
static_cast<Base&&
>(std::move(other)));
196 template <
size_t kOtherCapacity>
200 Base::operator=(
static_cast<Base&&
>(std::move(other)));
204 template <
typename T,
typename = EnableIfIterable<T>>
206 Base::operator=(other);
212 static constexpr size_type max_size() {
return capacity(); }
213 static constexpr size_type capacity() {
return kCapacity; }
224template <
typename ValueType,
typename CountAndCapacityType>
227 BasicInlineDequeImpl<ValueType, CountAndCapacityType, kGenericSized>,
229 CountAndCapacityType> {
234 CountAndCapacityType>;
237 using typename Base::const_iterator;
238 using typename Base::const_pointer;
239 using typename Base::const_reference;
240 using typename Base::difference_type;
241 using typename Base::iterator;
242 using typename Base::pointer;
243 using typename Base::reference;
244 using typename Base::size_type;
245 using typename Base::value_type;
257 for (
auto&& item : other) {
258 Base::emplace_back(std::move(item));
264 using Base::operator=;
268 [[nodiscard]]
bool full()
const noexcept {
280 template <
size_t kCapacity>
281 using Derived = RawStorage<
290 pointer data() {
return static_cast<Derived<0>*
>(
this)->data(); }
291 const_pointer data()
const {
292 return static_cast<const Derived<0>*
>(
this)->data();
298 static constexpr bool kFixedCapacity =
true;
Definition: inline_deque.h:229
Definition: inline_deque.h:77
BasicInlineDequeImpl(size_type count)
Constructs with count default-initialized elements.
Definition: inline_deque.h:107
BasicInlineDequeImpl & operator=(BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &&other) noexcept
Move assigns for mismatched capacity.
Definition: inline_deque.h:197
BasicInlineDequeImpl(const BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &other)
Definition: inline_deque.h:124
BasicInlineDequeImpl & operator=(BasicInlineDequeImpl &&other) noexcept
Move assigns for matching capacity.
Definition: inline_deque.h:190
BasicInlineDequeImpl & operator=(const BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &other)
Definition: inline_deque.h:181
BasicInlineDequeImpl & operator=(const std::initializer_list< value_type > &list)
Copy assigns from list.
Definition: inline_deque.h:165
BasicInlineDequeImpl() noexcept
Constructs with zero elements.
Definition: inline_deque.h:94
BasicInlineDequeImpl(BasicInlineDequeImpl< ValueType, CountAndCapacityType, kOtherCapacity > &&other) noexcept
Move constructs for mismatched capacity.
Definition: inline_deque.h:137
BasicInlineDequeImpl(BasicInlineDequeImpl &&other) noexcept
Move constructs for matching capacity.
Definition: inline_deque.h:131
BasicInlineDequeImpl(const std::initializer_list< value_type > &list)
Copy constructs from an initializer list.
Definition: inline_deque.h:144
BasicInlineDequeImpl & operator=(const BasicInlineDequeImpl &other)
Copy assigns for matching capacity.
Definition: inline_deque.h:172
BasicInlineDequeImpl(const BasicInlineDequeImpl &other)
Copy constructs for matching capacity.
Definition: inline_deque.h:118
BasicInlineDequeImpl(size_type count, const_reference value)
Constructs with count copies of value.
Definition: inline_deque.h:102
BasicInlineDequeImpl(const T &other)
Copy constructor for arbitrary iterables.
Definition: inline_deque.h:150
BasicInlineDequeImpl(InputIterator start, InputIterator finish)
Copy constructs from an iterator.
Definition: inline_deque.h:113
Definition: generic_deque.h:180
constexpr size_type size() const noexcept
Returns the number of elements in the deque.
Definition: generic_deque.h:64
constexpr size_type capacity() const noexcept
Returns the maximum number of elements in the deque.
Definition: generic_deque.h:69
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:211
The Pigweed namespace.
Definition: alignment.h:27
Definition: constexpr_tag.h:48