3 /// C++ smart pointer template that can call unique free
9 Net Direct Inc. (http://www.netdirect.ca/),
10 and Chris Frey <cdfrey@foursquare.net>
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU General Public License in the COPYING file at the
22 root directory of this project for more details.
25 #ifndef __REUSE_FSMARTPTR_H__
26 #define __REUSE_FSMARTPTR_H__
28 // A special smart pointer for pointer handling.
29 // Behaves like std::auto_ptr<> in that only one object
30 // at a time owns the pointer, and destruction frees it.
31 template <class T
, class FT
, void (*FreeFunc
)(FT
*pt
)>
37 fSmartPtr() : m_pt(0) {}
38 fSmartPtr(T
*pt
) : m_pt(pt
) {}
39 fSmartPtr(const fSmartPtr
&sp
) : m_pt(sp
.m_pt
)
49 fSmartPtr
& operator=(T
*pt
)
56 fSmartPtr
& operator=(const fSmartPtr
&sp
)