17template <
typename T>
class List;
18template <
typename T,
size_t N>
class Array;
34 using Iterator =
typename std::span<T>::iterator;
53 Span(
T *ptr,
size_t count) : d(ptr, count) {}
143 const T &
front()
const {
return d.front(); }
149 const T &
back()
const {
return d.back(); }
177 return Span(d.data() + offset, count);
186 return Span(d.data(), count);
195 return Span(d.data() + d.size() - count, count);
205 template <
typename Func>
207 for(
size_t i = 0;
i < d.size(); ++
i) func(d[
i]);
Fixed-size array container wrapping std::array.
Definition array.h:35
Dynamic array container wrapping std::vector.
Definition list.h:40
RevIterator rbegin() noexcept
Returns a mutable reverse iterator to the last element.
Definition list.h:178
Iterator begin() noexcept
Returns a mutable iterator to the first element.
Definition list.h:158
Iterator end() noexcept
Returns a mutable iterator to one past the last element.
Definition list.h:198
RevIterator rend() noexcept
Returns a mutable reverse iterator to one before the first element.
Definition list.h:218
Non-owning view over contiguous storage, wrapping std::span.
Definition span.h:31
typename std::span< T >::iterator Iterator
Mutable forward iterator.
Definition span.h:34
RevIterator rend() noexcept
Returns a mutable reverse iterator to one before the first element.
Definition span.h:110
Span(const Span &other)=default
Copy constructor.
Span first(size_t count)
Returns a span of the first count elements.
Definition span.h:185
T & front()
Returns a reference to the first element.
Definition span.h:140
RevIterator revBegin() noexcept
Returns a mutable reverse iterator to the last element.
Definition span.h:107
const T * data() const noexcept
Returns a pointer to the underlying contiguous storage.
Definition span.h:155
RevIterator rbegin() noexcept
Returns a mutable reverse iterator to the last element.
Definition span.h:104
ConstIterator end() const noexcept
Returns a const iterator to one past the last element.
Definition span.h:95
T * data() noexcept
Returns a pointer to the underlying contiguous storage.
Definition span.h:152
const T & operator[](size_t index) const
Returns a reference to the element at index without bounds checking.
Definition span.h:137
Span(Array< T, N > &arr)
Constructs a span from an Array.
Definition span.h:75
typename std::span< const T >::iterator ConstIterator
Const forward iterator.
Definition span.h:37
typename std::span< T >::reverse_iterator RevIterator
Mutable reverse iterator.
Definition span.h:40
void forEach(Func &&func) const
Calls func for every element.
Definition span.h:206
ConstRevIterator crend() const noexcept
Returns a const reverse iterator to one before the first element.
Definition span.h:122
ConstRevIterator constRevBegin() const noexcept
Returns a const reverse iterator to the last element.
Definition span.h:119
Iterator end() noexcept
Returns a mutable iterator to one past the last element.
Definition span.h:92
Span()=default
Default constructor. Creates an empty span.
Span(T(&arr)[N])
Constructs a span from a C array.
Definition span.h:67
ConstIterator constBegin() const noexcept
Returns a const iterator to the first element.
Definition span.h:98
size_t size() const noexcept
Returns the number of elements.
Definition span.h:163
typename std::span< const T >::reverse_iterator ConstRevIterator
Const reverse iterator.
Definition span.h:43
T & back()
Returns a reference to the last element.
Definition span.h:146
const T & front() const
Returns a reference to the first element.
Definition span.h:143
bool isEmpty() const noexcept
Returns true if the span has no elements.
Definition span.h:160
ConstIterator constEnd() const noexcept
Returns a const iterator to one past the last element.
Definition span.h:101
Span subspan(size_t offset, size_t count)
Returns a sub-span starting at offset with count elements.
Definition span.h:176
Iterator begin() noexcept
Returns a mutable iterator to the first element.
Definition span.h:86
ConstRevIterator crbegin() const noexcept
Returns a const reverse iterator to the last element.
Definition span.h:116
Span(List< T > &list)
Constructs a span from a List.
Definition span.h:59
Span last(size_t count)
Returns a span of the last count elements.
Definition span.h:194
ConstIterator begin() const noexcept
Returns a const iterator to the first element.
Definition span.h:89
size_t sizeBytes() const noexcept
Returns the size in bytes.
Definition span.h:166
RevIterator revEnd() noexcept
Returns a mutable reverse iterator to one before the first element.
Definition span.h:113
Span & operator=(const Span &other)=default
Copy assignment operator.
const T & back() const
Returns a reference to the last element.
Definition span.h:149
Span(T *ptr, size_t count)
Constructs a span from a pointer and size.
Definition span.h:53
ConstRevIterator constRevEnd() const noexcept
Returns a const reverse iterator to one before the first element.
Definition span.h:125
T & operator[](size_t index)
Returns a reference to the element at index without bounds checking.
Definition span.h:134
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19