Commit 26450bdc authored by Mark Olesen's avatar Mark Olesen
Browse files

modified xfer class make transfer optional

parent 4caaeaef
......@@ -60,18 +60,24 @@ class xfer
//- Pointer to temporary object
mutable T* ptr_;
// Private Member Functions
//- Disallow default bitwise copy construct
xfer(const xfer<T>&);
public:
// Constructors
//- Null constructor, transfer later by assignment
//- Null constructor
// Can be used later to transfer by assignment
inline xfer();
//- Construct by transferring the parameter contents into the object
inline xfer(T&);
//- Construct by copying or by transferring the parameter contents
inline xfer(T&, bool allowTransfer=false);
//- Construct by transferring the parameter contents into the object
inline xfer(const xfer<T>&);
//- Copy constructor
inline xfer(const T&);
// Destructor
......
......@@ -34,20 +34,27 @@ inline Foam::xfer<T>::xfer()
template<class T>
inline Foam::xfer<T>::xfer(T& t)
inline Foam::xfer<T>::xfer(T& t, bool allowTransfer)
:
ptr_(new T)
{
ptr_->transfer(t);
if (allowTransfer)
{
ptr_->transfer(t);
}
else
{
ptr_->operator=(t);
}
}
template<class T>
inline Foam::xfer<T>::xfer(const xfer<T>& t)
inline Foam::xfer<T>::xfer(const T& t)
:
ptr_(new T)
{
ptr_->transfer(*(t.ptr_));
ptr_->operator=(t);
}
......
Supports Markdown
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