This commit is contained in:
Tomerkm 2025-06-03 19:26:08 +02:00 committed by GitHub
commit 5bc0af80e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,13 +53,12 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
std::pair<iterator, bool> emplace(const key_type& key, T&& t) std::pair<iterator, bool> emplace(const key_type& key, T&& t)
{ {
for (auto it = this->begin(); it != this->end(); ++it) auto iter = this->find(key);
if (iter != this->end())
{ {
if (m_compare(it->first, key)) return {iter, false};
{
return {it, false};
}
} }
Container::emplace_back(key, std::forward<T>(t)); Container::emplace_back(key, std::forward<T>(t));
return {std::prev(this->end()), true}; return {std::prev(this->end()), true};
} }