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];