mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 18:36:31 +00:00
17 lines
436 B
C++
17 lines
436 B
C++
|
#include "alloc.hpp"
|
||
|
#include <format>
|
||
|
#include <iostream>
|
||
|
|
||
|
using namespace sliger::heap;
|
||
|
|
||
|
auto Array::at(int32_t index) & -> Value&
|
||
|
{
|
||
|
if (index >= static_cast<int32_t>(this->values.size()) || index < 0) {
|
||
|
std::cout << std::format(
|
||
|
"index not in range, expected to be in range (0..{}), got: {}",
|
||
|
this->values.size(), index);
|
||
|
exit(1);
|
||
|
}
|
||
|
return values.at(static_cast<size_t>(index));
|
||
|
}
|