array_map: introduce at()
This commit is contained in:
committed by
Avi Kivity
parent
791797669f
commit
4311f5dafa
@@ -20,6 +20,13 @@ public:
|
||||
}
|
||||
Value& operator[](size_t key) { return _a[key]; }
|
||||
const Value& operator[](size_t key) const { return _a[key]; }
|
||||
|
||||
Value& at(size_t key) {
|
||||
if (key >= Max) {
|
||||
throw std::out_of_range(std::to_string(key) + " >= " + std::to_string(Max));
|
||||
}
|
||||
return _a[key];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user