xo-alloc2: working operator* for AAllocIterator

This commit is contained in:
Roland Conybeare 2025-12-21 16:20:13 -05:00
commit c6fbaf7b5e
5 changed files with 36 additions and 2 deletions

View file

@ -27,6 +27,8 @@ namespace xo {
return O::iface()->compare(O::data(), other); }
void next() noexcept { O::iface()->next(O::data()); }
AllocInfo operator*() const noexcept { return deref(); }
/** triggers operator++ in obj<RAllocIterator<Object>> **/
void _preincrement() noexcept { this->next(); }

View file

@ -32,7 +32,7 @@ namespace xo {
if (!other)
return cmpresult::incomparable();
DArenaIterator & other_ix = *other;
DArenaIterator & other_ix = *other.data();
log && log(xtag("&other_ix", &other_ix),
xtag("other_ix.arena", other_ix.arena_),

View file

@ -25,7 +25,7 @@ namespace xo {
if (!other)
return cmpresult::incomparable();
DX1CollectorIterator & other_ix = *other;
DX1CollectorIterator & other_ix = *other.data();
return ix.compare(other_ix);
}

View file

@ -269,6 +269,22 @@ namespace xo {
REQUIRE(ix == end_ix);
}
}
// repeat, this time using range iteration
{
DArena scratch_mm
= DArena::map(
ArenaConfig{
.size_ = 4*1024,
.hugepage_z_ = 4*1024});
for (const auto & info : a1o.alloc_range(scratch_mm)) {
REQUIRE(info.is_valid());
REQUIRE(info.size() == padding::with_padding(req_z));
REQUIRE(info.payload().first == mem);
REQUIRE(info.payload().second == mem + info.size());
}
}
}
} /*namespace ut*/

View file

@ -198,6 +198,22 @@ namespace xo {
REQUIRE(ix == end_ix);
}
}
// repeat, this time using range iteration
{
DArena scratch_mm
= DArena::map(
ArenaConfig{
.size_ = 4*1024,
.hugepage_z_ = 4*1024});
for (const auto & info : a1o.alloc_range(scratch_mm)) {
REQUIRE(info.is_valid());
REQUIRE(info.size() == padding::with_padding(req_z));
REQUIRE(info.payload().first == mem);
REQUIRE(info.payload().second == mem + info.size());
}
}
}
} /*namespace ut*/
} /*namespace xo*/