From 4311f5dafa7a63549fec24ee42a89b55e0a61e65 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Tue, 16 Sep 2014 16:48:57 +0200 Subject: [PATCH] array_map: introduce at() --- core/array_map.hh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/array_map.hh b/core/array_map.hh index 35643eb945..1766478680 100644 --- a/core/array_map.hh +++ b/core/array_map.hh @@ -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]; + } };