1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
30 inline const Foam::Xfer<T>& Foam::Xfer<T>::null()
32 return *reinterpret_cast< Xfer<T>* >(0);
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 inline Foam::Xfer<T>::Xfer(T* p)
46 inline Foam::Xfer<T>::Xfer(T& t, bool allowTransfer)
62 inline Foam::Xfer<T>::Xfer(const T& t)
71 inline Foam::Xfer<T>::Xfer(const Xfer<T>& t)
75 ptr_->transfer(*(t.ptr_));
79 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 inline Foam::Xfer<T>::~Xfer()
89 // * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * //
92 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
95 inline void Foam::Xfer<T>::operator=(T& t)
102 inline void Foam::Xfer<T>::operator=(const Xfer<T>& t)
104 // silently ignore attempted copy to self
107 ptr_->transfer(*(t.ptr_));
113 inline T& Foam::Xfer<T>::operator()() const
120 inline T* Foam::Xfer<T>::operator->() const
126 // * * * * * * * * * * * * * Helper Functions * * * * * * * * * * * * * * * //
130 inline Foam::Xfer<T> Foam::xferCopy(const T& t)
132 return Foam::Xfer<T>(t);
137 inline Foam::Xfer<T> Foam::xferMove(T& t)
139 return Foam::Xfer<T>(t, true);
144 inline Foam::Xfer<T> Foam::xferTmp(Foam::tmp<T>& tt)
146 return Foam::Xfer<T>(tt(), tt.isTmp());
150 template<class To, class From>
151 inline Foam::Xfer<To> Foam::xferCopyTo(const From& t)
159 template<class To, class From>
160 inline Foam::Xfer<To> Foam::xferMoveTo(From& t)
168 // ************************************************************************* //