mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional HashTable emplace/insert/set methods (#1286)
- support move insert/set and emplace insertion. These adjustments can be used for improved memory efficiency, and allow hash tables of non-copyable objects (eg, std::unique_ptr). - extend special HashTable output treatment to include pointer-like objects such as autoPtr and unique_ptr. ENH: HashTable::at() method with checking. Fatal if entry does not exist.
This commit is contained in:
committed by
Andrew Heather
parent
e30dc962b3
commit
ac317699d8
@ -249,6 +249,28 @@ int main(int argc, char *argv[])
|
||||
Info<< nl << "Ending scope" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
Info<< nl << "Table<labelList> copy/move/emplace insertion" << nl;
|
||||
|
||||
HashTable<labelList> ltable1(0);
|
||||
ltable1.insert("abc", identity(2));
|
||||
ltable1.insert("def", identity(3));
|
||||
ltable1.insert("ghi", identity(4));
|
||||
ltable1.emplace("jkl", 10, -35);
|
||||
ltable1.emplace("mno");
|
||||
|
||||
labelList list1(identity(4, -4));
|
||||
|
||||
Info<<"move insert " << list1 << nl;
|
||||
|
||||
ltable1.insert("pqr", std::move(list1));
|
||||
|
||||
Info<<"after insert " << list1 << nl;
|
||||
|
||||
Info<< nl << "HashTable<labelList>: "
|
||||
<< ltable1 << nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user