Исправлен тип возвращаемого значения в hashStrMap::at

This commit is contained in:
Aleksandr Orefkov 2025-11-10 20:35:35 +03:00
parent 8cff9ea543
commit b61296939c
2 changed files with 13 additions and 4 deletions

View File

@ -5631,17 +5631,17 @@ public:
return try_emplace(std::forward<Key>(key)).first->second; return try_emplace(std::forward<Key>(key)).first->second;
} }
auto at(const StoreType<K>& key) { decltype(auto) at(const StoreType<K>& key) {
return hash_t::at(key); return hash_t::at(key);
} }
auto at(const StoreType<K>& key) const { decltype(auto) at(const StoreType<K>& key) const {
return hash_t::at(key); return hash_t::at(key);
} }
auto at(simple_str<K> key) { decltype(auto) at(simple_str<K> key) {
return hash_t::at(toStoreType(key)); return hash_t::at(toStoreType(key));
} }
auto at(simple_str<K> key) const { decltype(auto) at(simple_str<K> key) const {
return hash_t::at(toStoreType(key)); return hash_t::at(toStoreType(key));
} }

View File

@ -1751,4 +1751,13 @@ TEST(SimStr, InitFromLValueStdStrings) {
EXPECT_EQ(ssa(get_string_cref()), "str"); EXPECT_EQ(ssa(get_string_cref()), "str");
} }
TEST(SimStr, HashStrMapAt) {
hashStrMapA<int> 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 } // namespace simstr::tests