I removed a duplicate code and used a function does the job.

pull/4057/head
Tomerkm 2023-06-16 17:41:07 +03:00
parent 83bf8dd35e
commit 87ae0e6b6d
1 changed files with 4 additions and 5 deletions

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)
{
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 {it, false};
}
return {iter, false};
}
Container::emplace_back(key, std::forward<T>(t));
return {std::prev(this->end()), true};
}