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
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()
template<class T>
struct offsetOp
......
......@@ -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.
template<class T>
struct sizeOp
......
Markdown is supported
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