mirror of https://github.com/nlohmann/json.git
I removed a duplicate code and used a function does the job.
parent
83bf8dd35e
commit
87ae0e6b6d
|
@ -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};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue