add TryEmplace to TMap
This commit is contained in:
parent
e2026dca38
commit
88a55be561
1 changed files with 12 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue