diff --git a/src/Collections/List.hpp b/src/Collections/List.hpp index f14aa19..5f70a61 100644 --- a/src/Collections/List.hpp +++ b/src/Collections/List.hpp @@ -22,7 +22,7 @@ namespace Arbutils::Collections { inline const ValueT& At(size_t index) const { #ifndef NO_ASSERT - if (index >= _vector.size()) { + if (index >= _vector.size() || index < 0) { std::stringstream ss; ss << "Index " << index << " is out of bounds."; throw std::logic_error(ss.str()); @@ -32,7 +32,7 @@ namespace Arbutils::Collections { } inline ValueT& At(size_t index) { #ifndef NO_ASSERT - if (index >= _vector.size()) { + if (index >= _vector.size() || index < 0) { std::stringstream ss; ss << "Index " << index << " is out of bounds."; throw std::logic_error(ss.str());