Skip to content
Snippets Groups Projects
Commit 26450bdc authored by Mark Olesen's avatar Mark Olesen
Browse files

modified xfer class make transfer optional

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