xo-object2: + DArray::at() + utests
This commit is contained in:
parent
0a6f449b3b
commit
87dd88beec
5 changed files with 90 additions and 4 deletions
|
|
@ -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_) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue