ENH: PtrList iterate over non-null entries (#2702)
- the iterator/const_iterator now skip any nullptr entries, which enables the following code to work even if the PtrList contains nullptr: for (const auto& intf : interfaces) { // Do something ... } - this is a change in behaviour compared to OpenFOAM-v2212 and earlier, but is non-breaking: * Lists without null entries will traverse exactly as before. * Lists with null entries will now traverse correctly without provoking a FatalError.
Showing
- applications/test/PtrList/Test-PtrList.C 26 additions, 4 deletionsapplications/test/PtrList/Test-PtrList.C
- src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H 216 additions, 54 deletionssrc/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H
- src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H 64 additions, 80 deletionssrc/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H
Please register or sign in to comment