ENH: add Xfer rvalue(), valid() methods

- rvalue() is a (transitional) means of converting Xfer content to a
  reference for move construct, move assign semantics.

- valid() method for consistency with autoPtr and tmp classes
This commit is contained in:
Mark Olesen
2018-02-28 09:30:31 +01:00
parent 7e84380783
commit 081783db6c
3 changed files with 53 additions and 7 deletions

View File

@ -39,6 +39,16 @@ Description
using namespace Foam;
template<class Type>
void printInfo(const Xfer<Type>& xf)
{
Info<<" address:" << long(xf.get()) << nl
<<" isNull = " << isNull(xf) << nl
<<" notNull = " << notNull(xf) << nl
<<" valid() = " << xf.valid() << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
@ -55,6 +65,18 @@ int main(int argc, char *argv[])
lstA[i] = 5 - i;
}
// Information about null-object
Info<<"nullObject:" << nl;
printInfo(Xfer<labelList>::null());
{
// This probably needs more work...
Xfer<labelList> xf = Xfer<labelList>::null();
Info<<"copy of nullObject:" << nl;
printInfo(xf);
}
Info<< "lstA: " << lstA << nl
<< "lstC: " << lstC << nl;