mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added xfer::operator->() for easier de-referencing of underlying methods
This commit is contained in:
@ -55,8 +55,6 @@ int main(int argc, char *argv[])
|
|||||||
xfer<List<label> > xA(lstA, true);
|
xfer<List<label> > xA(lstA, true);
|
||||||
xfer<List<label> > xB;
|
xfer<List<label> > xB;
|
||||||
|
|
||||||
// List<label> lstB( xferTmp(List<label>, lstC) );
|
|
||||||
// List<label> lstB( xfer<List<label> >(lstC) );
|
|
||||||
List<label> lstB( xA );
|
List<label> lstB( xA );
|
||||||
|
|
||||||
Info<< "xA: " << *xA << endl;
|
Info<< "xA: " << *xA << endl;
|
||||||
@ -74,12 +72,28 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "lstC: " << lstC << endl;
|
Info<< "lstC: " << lstC << endl;
|
||||||
|
|
||||||
xB = xA;
|
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<< "xA: " << *xA << endl;
|
||||||
Info<< "xB: " << *xB << endl;
|
Info<< "xB: " << *xB << endl;
|
||||||
Info<< "lstA: " << lstA << endl;
|
Info<< "lstA: " << lstA << endl;
|
||||||
Info<< "lstB: " << lstB << endl;
|
Info<< "lstB: " << lstB << endl;
|
||||||
Info<< "lstC: " << lstC << 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ Description
|
|||||||
of objects of type \<T\>.
|
of objects of type \<T\>.
|
||||||
|
|
||||||
Since it is decided upon construction of the xfer object whether the
|
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.
|
object can be transferred unconditionally.
|
||||||
|
|
||||||
This greatly simplifies defining the constructors for other classes
|
This greatly simplifies defining the constructors for other classes
|
||||||
@ -104,6 +104,9 @@ public:
|
|||||||
//- Reference to the underlying datatype
|
//- Reference to the underlying datatype
|
||||||
inline T& operator*() const;
|
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_;
|
return *ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T* Foam::xfer<T>::operator->() const
|
||||||
|
{
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user