Commit a174f13f authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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).
parent 57cfe2b5
...@@ -93,17 +93,6 @@ SourceFiles ...@@ -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
......
...@@ -615,6 +615,31 @@ struct Hash<UList<T>> ...@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment