16#include "pw_allocator/block/contiguous.h"
18namespace pw::allocator {
34template <
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 constexpr bool operator!=(
const Iterator& other);
55 constexpr Derived* operator*() {
return block_; }
72 constexpr explicit Range(Derived* begin) : begin_(begin), end_(nullptr) {}
75 constexpr Range(Derived* begin_inclusive, Derived* end_inclusive)
76 : begin_(begin_inclusive), end_(end_inclusive->Next()) {}
78 constexpr Iterator& begin() {
return begin_; }
79 constexpr Iterator& end() {
return end_; }
89template <
typename BlockType>
90struct is_iterable : std::is_base_of<internal::IterableBase, BlockType> {};
93template <
typename BlockType>
100template <
typename Derived>
102 block_ = block_ !=
nullptr ? block_->Next() :
nullptr;
106template <
typename Derived>
107constexpr bool IterableBlock<Derived>::Iterator::operator!=(
108 const Iterator& other) {
109 return block_ != other.block_;
Definition: iterable.h:50
Definition: iterable.h:69
constexpr Range(Derived *begin)
Constructs a range including begin and all valid following blocks.
Definition: iterable.h:72
constexpr Range(Derived *begin_inclusive, Derived *end_inclusive)
Constructs a range of blocks from begin to end, inclusively.
Definition: iterable.h:75
Definition: iterable.h:35
constexpr bool is_iterable_v
Helper variable template for is_iterable<BlockType>::value.
Definition: iterable.h:94
Definition: iterable.h:22
Definition: iterable.h:90