16#include "pw_allocator/block/contiguous.h"
18namespace pw::allocator {
32template <
typename Derived>
38 static_assert(is_contiguous_v<Derived>,
39 "Types derived from IterableBlock must also derive "
40 "from ContiguousBlock");
52 constexpr explicit Iterator(Derived* block) : block_(block) {}
54 block_ = block_ !=
nullptr ? block_->Next() :
nullptr;
57 constexpr bool operator!=(
const Iterator& other) {
58 return block_ != other.block_;
60 constexpr Derived* operator*() {
return block_; }
77 constexpr explicit Range(Derived* begin) : begin_(begin), end_(nullptr) {}
80 constexpr Range(Derived* begin_inclusive, Derived* end_inclusive)
81 : begin_(begin_inclusive), end_(end_inclusive->Next()) {}
83 constexpr Iterator& begin() {
return begin_; }
84 constexpr Iterator& end() {
return end_; }
94template <
typename BlockType>
95struct is_iterable : std::is_base_of<internal::IterableBase, BlockType> {};
98template <
typename BlockType>
Definition: iterable.h:50
Definition: iterable.h:74
constexpr Range(Derived *begin)
Constructs a range including begin and all valid following blocks.
Definition: iterable.h:77
constexpr Range(Derived *begin_inclusive, Derived *end_inclusive)
Constructs a range of blocks from begin to end, inclusively.
Definition: iterable.h:80
Definition: iterable.h:33
Definition: iterable.h:22
Definition: iterable.h:95