From 5df29246a58fcadb406598c02fc37a04bec9d75e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 17 Jul 2024 19:43:54 +0300 Subject: [PATCH] Fix util::at(vector) --- libs/util/include/psemek/util/at.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/util/include/psemek/util/at.hpp b/libs/util/include/psemek/util/at.hpp index fcfb4496..a69f7b89 100644 --- a/libs/util/include/psemek/util/at.hpp +++ b/libs/util/include/psemek/util/at.hpp @@ -60,7 +60,16 @@ namespace psemek::util } template - auto & at(std::vector && container, Key const & key) + auto & at(std::vector & container, Key const & key) + { + if (key < container.size()) + return container[key]; + + throw key_error(key); + } + + template + auto & at(std::vector const & container, Key const & key) { if (key < container.size()) return container[key];