mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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>>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
|||||||
Reference in New Issue
Block a user