From b61296939cadc80ac4f5d99b462acad255f89aae Mon Sep 17 00:00:00 2001 From: Aleksandr Orefkov Date: Mon, 10 Nov 2025 20:35:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=82=D0=B8=D0=BF=20=D0=B2=D0=BE=D0=B7=D0=B2?= =?UTF-8?q?=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D0=BC=D0=BE=D0=B3=D0=BE=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20hashStrMa?= =?UTF-8?q?p::at?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/simstr/sstring.h | 8 ++++---- tests/test_str.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/simstr/sstring.h b/include/simstr/sstring.h index df5b9c4..9b056fc 100644 --- a/include/simstr/sstring.h +++ b/include/simstr/sstring.h @@ -5631,17 +5631,17 @@ public: return try_emplace(std::forward(key)).first->second; } - auto at(const StoreType& key) { + decltype(auto) at(const StoreType& key) { return hash_t::at(key); } - auto at(const StoreType& key) const { + decltype(auto) at(const StoreType& key) const { return hash_t::at(key); } - auto at(simple_str key) { + decltype(auto) at(simple_str key) { return hash_t::at(toStoreType(key)); } - auto at(simple_str key) const { + decltype(auto) at(simple_str key) const { return hash_t::at(toStoreType(key)); } diff --git a/tests/test_str.cpp b/tests/test_str.cpp index a2d60fb..1b4fa0b 100644 --- a/tests/test_str.cpp +++ b/tests/test_str.cpp @@ -1751,4 +1751,13 @@ TEST(SimStr, InitFromLValueStdStrings) { EXPECT_EQ(ssa(get_string_cref()), "str"); } +TEST(SimStr, HashStrMapAt) { + hashStrMapA test = { + {"Test"_h, 1} + }; + EXPECT_EQ(test.find("Test")->second, 1); + test.at("Test") = 2; + EXPECT_EQ(test.find("Test")->second, 2); +} + } // namespace simstr::tests