-
- Downloads
ENH: HashTable cfind() method returning a const_iterator
- This follows the same idea as cbegin/cend and is helpful when using C++11 auto to ensure we have unambiguous const-safe access. Previously: ==== typename someLongClass::const_iterator iter = someTable.find(key); ... later on: *iter = value; // Oops, but caught by compiler. We can save some typing with auto, but it is uncertain what we get: ==== auto iter = someTable.find(key); // iterator or const_iterator? // depends on someTable having const or non-const access. ... later on: *iter = value; // Oops, but not caught by compiler. Using cfind instead, auto will deduce const_iterator as the type: ==== auto iter = someTable.cfind(key); // definitely const_iterator ... later on: *iter = value; // Oops, but caught by compiler.
Showing
- src/OpenFOAM/containers/HashTables/HashTable/HashTable.C 13 additions, 2 deletionssrc/OpenFOAM/containers/HashTables/HashTable/HashTable.C
- src/OpenFOAM/containers/HashTables/HashTable/HashTable.H 4 additions, 0 deletionssrc/OpenFOAM/containers/HashTables/HashTable/HashTable.H
- src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C 11 additions, 0 deletions...M/containers/HashTables/StaticHashTable/StaticHashTable.C
- src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H 4 additions, 0 deletions...M/containers/HashTables/StaticHashTable/StaticHashTable.H
- src/OpenFOAM/containers/NamedEnum/NamedEnum.H 2 additions, 2 deletionssrc/OpenFOAM/containers/NamedEnum/NamedEnum.H
Loading
Please register or sign in to comment