add TryEmplace to TMap

This commit is contained in:
Ricardo Luís Vaz Silva 2025-04-16 23:01:33 -03:00
commit 88a55be561

View file

@ -1380,6 +1380,18 @@ public:
return n->Pair.Value;
}
template<typename... Args>
VT &TryEmplace(const KT key, Args&&... args)
{
Node *n = FindKey(key);
if (n == NULL)
{
n = NewKey(key);
::new(&n->Pair.Value) VT(std::forward<Args>(args)...);
}
return n->Pair.Value;
}
//=======================================================================
//
// Remove