From 86f0e1ca086923080a50bcb5bbab889406775dc3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 1 Apr 2021 21:57:26 -0500 Subject: [PATCH] [ox/std] Fix non-const HashMap::at --- deps/ox/src/ox/std/hashmap.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/deps/ox/src/ox/std/hashmap.hpp b/deps/ox/src/ox/std/hashmap.hpp index 66d58ed2..44f328b6 100644 --- a/deps/ox/src/ox/std/hashmap.hpp +++ b/deps/ox/src/ox/std/hashmap.hpp @@ -133,14 +133,18 @@ T &HashMap::operator[](K k) { template Result HashMap::at(K k) { - return &operator[](k); + auto p = access(m_pairs, k); + if (!p) { + return {nullptr, OxError(1, "Value not found for key")}; + } + return &p->value; } template Result HashMap::at(K k) const { auto p = access(m_pairs, k); if (!p) { - return {nullptr, OxError(1)}; + return {nullptr, OxError(1, "Value not found for key")}; } return &p->value; }