16#include "pw_allocator/block/contiguous.h"
18namespace pw::allocator {
34template <
typename Derived>
40 static_assert(is_contiguous_v<Derived>,
41 "Types derived from IterableBlock must also derive "
42 "from ContiguousBlock");
54 constexpr explicit Iterator(Derived* block) : block_(block) {}
56 block_ = block_ !=
nullptr ? block_->Next() :
nullptr;
59 constexpr bool operator!=(
const Iterator& other) {
60 return block_ != other.block_;
62 constexpr Derived* operator*() {
return block_; }
79 constexpr explicit Range(Derived* begin) : begin_(begin), end_(nullptr) {}
82 constexpr Range(Derived* begin_inclusive, Derived* end_inclusive)
83 : begin_(begin_inclusive), end_(end_inclusive->Next()) {}
85 constexpr Iterator& begin() {
return begin_; }
86 constexpr Iterator& end() {
return end_; }
96template <
typename BlockType>
97struct is_iterable : std::is_base_of<internal::IterableBase, BlockType> {};
100template <
typename BlockType>
Definition: iterable.h:52
Definition: iterable.h:76
constexpr Range(Derived *begin)
Constructs a range including begin and all valid following blocks.
Definition: iterable.h:79
constexpr Range(Derived *begin_inclusive, Derived *end_inclusive)
Constructs a range of blocks from begin to end, inclusively.
Definition: iterable.h:82
Definition: iterable.h:35
constexpr bool is_iterable_v
Helper variable template for is_iterable<BlockType>::value.
Definition: iterable.h:101
Definition: iterable.h:22
Definition: iterable.h:97