ENH: define accessOp<T> and emptyOp<T> in UList.H

- The dummy accessOp can be useful outside of ListListOps.
- New emptyOp for using as a filter predicate (for example).
This commit is contained in:
Mark Olesen
2019-01-14 09:47:52 +01:00
parent 57cfe2b5ef
commit a174f13f4b
2 changed files with 25 additions and 11 deletions

View File

@ -93,17 +93,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
//- Dummy access operator for ListListOps::combine()
template<class T>
struct accessOp
{
const T& operator()(const T& x) const
{
return x;
}
};
//- Offset operator for ListListOps::combineOffset() //- Offset operator for ListListOps::combineOffset()
template<class T> template<class T>
struct offsetOp struct offsetOp

View File

@ -615,6 +615,31 @@ struct Hash<UList<T>>
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Object access operator or list access operator.
//- \sa ListListOps::combine()
template<class T>
struct accessOp
{
const T& operator()(const T& obj) const
{
return obj;
}
};
//- Test if object is empty, typically using its empty() method.
template<class T>
struct emptyOp
{
inline bool operator()(const T& obj) const
{
return obj.empty();
}
};
//- Extract size (as label) from an object, typically using its size() method. //- Extract size (as label) from an object, typically using its size() method.
template<class T> template<class T>
struct sizeOp struct sizeOp