xo-object2: + DArray::at() + utests

This commit is contained in:
Roland Conybeare 2026-01-15 13:41:24 -05:00
commit 87dd88beec
5 changed files with 90 additions and 4 deletions

View file

@ -4,6 +4,8 @@
**/
#include "DArray.hpp"
#include <xo/indentlog/print/tostr.hpp>
#include <xo/indentlog/print/tag.hpp>
namespace xo {
using xo::mm::AGCObject;
@ -33,6 +35,19 @@ namespace xo {
return result;
}
obj<AGCObject>
DArray::at(size_type ix) const
{
if (ix < size_) {
return elts_[ix];
} else {
throw std::runtime_error(tostr("DArray::at: out-of-range index where [0..z) expected",
xtag("index", ix),
xtag("z", this->size())));
return obj<AGCObject>();
}
}
bool
DArray::push_back(obj<AGCObject> elt) noexcept {
if (size_ >= capacity_) {