added xfer::operator->() for easier de-referencing of underlying methods
This commit is contained in:
parent
dffbda287c
commit
70a38319d6
@ -55,8 +55,6 @@ int main(int argc, char *argv[])
|
||||
xfer<List<label> > xA(lstA, true);
|
||||
xfer<List<label> > xB;
|
||||
|
||||
// List<label> lstB( xferTmp(List<label>, lstC) );
|
||||
// List<label> lstB( xfer<List<label> >(lstC) );
|
||||
List<label> lstB( xA );
|
||||
|
||||
Info<< "xA: " << *xA << endl;
|
||||
@ -74,12 +72,28 @@ int main(int argc, char *argv[])
|
||||
Info<< "lstC: " << lstC << endl;
|
||||
|
||||
xB = xA;
|
||||
|
||||
List<label> lstD( xferCopy(List<label>, lstC) );
|
||||
List<label> lstE( xferMove(List<label>, lstC) );
|
||||
|
||||
// this must be empty
|
||||
List<label> lstF( xferCopy(List<label>, lstC) );
|
||||
|
||||
Info<< "xA: " << *xA << endl;
|
||||
Info<< "xB: " << *xB << endl;
|
||||
Info<< "lstA: " << lstA << endl;
|
||||
Info<< "lstB: " << lstB << endl;
|
||||
Info<< "lstC: " << lstC << endl;
|
||||
Info<< "lstD: " << lstD << endl;
|
||||
Info<< "lstE: " << lstE << endl;
|
||||
Info<< "lstF: " << lstF << endl;
|
||||
|
||||
Info<< "xB size: " << *xB << endl;
|
||||
|
||||
// clear the underlying List
|
||||
xB->clear();
|
||||
|
||||
Info<< "xB size: " << *xB << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ Description
|
||||
of objects of type \<T\>.
|
||||
|
||||
Since it is decided upon construction of the xfer object whether the
|
||||
parameter is to be copied or transferred, the contents of resulting
|
||||
parameter is to be copied or transferred, the contents of the resulting
|
||||
object can be transferred unconditionally.
|
||||
|
||||
This greatly simplifies defining the constructors for other classes
|
||||
@ -104,6 +104,9 @@ public:
|
||||
//- Reference to the underlying datatype
|
||||
inline T& operator*() const;
|
||||
|
||||
//- Pointer to the underlying datatype
|
||||
inline T* operator->() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -110,4 +110,10 @@ inline T& Foam::xfer<T>::operator*() const
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T* Foam::xfer<T>::operator->() const
|
||||
{
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
Loading…
Reference in New Issue
Block a user