xo-alloc2: working operator* for AAllocIterator
This commit is contained in:
parent
af1707aa03
commit
cb0add52df
8 changed files with 45 additions and 3 deletions
|
|
@ -27,6 +27,8 @@ namespace xo {
|
||||||
return O::iface()->compare(O::data(), other); }
|
return O::iface()->compare(O::data(), other); }
|
||||||
void next() noexcept { O::iface()->next(O::data()); }
|
void next() noexcept { O::iface()->next(O::data()); }
|
||||||
|
|
||||||
|
AllocInfo operator*() const noexcept { return deref(); }
|
||||||
|
|
||||||
/** triggers operator++ in obj<RAllocIterator<Object>> **/
|
/** triggers operator++ in obj<RAllocIterator<Object>> **/
|
||||||
void _preincrement() noexcept { this->next(); }
|
void _preincrement() noexcept { this->next(); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace xo {
|
||||||
if (!other)
|
if (!other)
|
||||||
return cmpresult::incomparable();
|
return cmpresult::incomparable();
|
||||||
|
|
||||||
DArenaIterator & other_ix = *other;
|
DArenaIterator & other_ix = *other.data();
|
||||||
|
|
||||||
log && log(xtag("&other_ix", &other_ix),
|
log && log(xtag("&other_ix", &other_ix),
|
||||||
xtag("other_ix.arena", other_ix.arena_),
|
xtag("other_ix.arena", other_ix.arena_),
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace xo {
|
||||||
if (!other)
|
if (!other)
|
||||||
return cmpresult::incomparable();
|
return cmpresult::incomparable();
|
||||||
|
|
||||||
DX1CollectorIterator & other_ix = *other;
|
DX1CollectorIterator & other_ix = *other.data();
|
||||||
|
|
||||||
return ix.compare(other_ix);
|
return ix.compare(other_ix);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,22 @@ namespace xo {
|
||||||
REQUIRE(ix == end_ix);
|
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 ut*/
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,22 @@ namespace xo {
|
||||||
REQUIRE(ix == end_ix);
|
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 ut*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,9 @@ namespace xo {
|
||||||
//iface_ = *std::launder(&iface_);
|
//iface_ = *std::launder(&iface_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NOPE
|
||||||
DRepr & operator*() { return *data_; }
|
DRepr & operator*() { return *data_; }
|
||||||
|
#endif
|
||||||
|
|
||||||
OObject & operator=(const OObject & oother) {
|
OObject & operator=(const OObject & oother) {
|
||||||
if (this != &oother) {
|
if (this != &oother) {
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,12 @@ namespace xo {
|
||||||
return obj(other.template downcast<DRepr>());
|
return obj(other.template downcast<DRepr>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** enabled when RRouter<AFacet> provides _preincrement.
|
||||||
|
* Note we don't need this trick for comparison operators,
|
||||||
|
* since return type is fixed.
|
||||||
|
*
|
||||||
|
* For example see comparison overloads in RAllocIterator.hpp
|
||||||
|
**/
|
||||||
obj & operator++() noexcept { this->_preincrement(); return *this; }
|
obj & operator++() noexcept { this->_preincrement(); return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ namespace xo {
|
||||||
REQUIRE(z1o.argument() == 0.25 * std::numbers::pi);
|
REQUIRE(z1o.argument() == 0.25 * std::numbers::pi);
|
||||||
REQUIRE(z1o.magnitude() == 1.0);
|
REQUIRE(z1o.magnitude() == 1.0);
|
||||||
|
|
||||||
*z1o = z1;
|
*z1o.data() = z1;
|
||||||
|
|
||||||
REQUIRE(z1o.data() == &z2);
|
REQUIRE(z1o.data() == &z2);
|
||||||
REQUIRE(z1o.xcoord() == 1.0);
|
REQUIRE(z1o.xcoord() == 1.0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue