From a174f13f4b1065c2c1bb0a45fbef4483689226ee Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 14 Jan 2019 09:47:52 +0100 Subject: [PATCH] ENH: define accessOp and emptyOp in UList.H - The dummy accessOp can be useful outside of ListListOps. - New emptyOp for using as a filter predicate (for example). --- .../Lists/ListListOps/ListListOps.H | 11 -------- src/OpenFOAM/containers/Lists/UList/UList.H | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H index 4d5616621a..7b8590afff 100644 --- a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H +++ b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H @@ -93,17 +93,6 @@ SourceFiles namespace Foam { -//- Dummy access operator for ListListOps::combine() -template -struct accessOp -{ - const T& operator()(const T& x) const - { - return x; - } -}; - - //- Offset operator for ListListOps::combineOffset() template struct offsetOp diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index aff773ac23..8d81d5f589 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -615,6 +615,31 @@ struct Hash> }; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Object access operator or list access operator. +//- \sa ListListOps::combine() +template +struct accessOp +{ + const T& operator()(const T& obj) const + { + return obj; + } +}; + + +//- Test if object is empty, typically using its empty() method. +template +struct emptyOp +{ + inline bool operator()(const T& obj) const + { + return obj.empty(); + } +}; + + //- Extract size (as label) from an object, typically using its size() method. template struct sizeOp