5 #ifndef CVMFS_UTIL_POINTER_H_
6 #define CVMFS_UTIL_POINTER_H_
12 #ifdef CVMFS_NAMESPACE_GUARD
13 namespace CVMFS_NAMESPACE_GUARD {
21 struct IsPointer {
static const bool value =
false; };
26 template <
class T,
class DerivedT>
40 return *(
static_cast<DerivedT*
>(
this));
43 inline bool IsValid()
const {
return (ref_ != NULL); }
44 inline T*
Release() { T* r = ref_; ref_ = NULL;
return r; }
45 inline void Destroy() { Free(); ref_ = NULL; }
49 static_cast<DerivedT*
>(
this)->Free();
62 using BaseT::operator=;
65 inline T&
operator*()
const {
return *BaseT::ref_; }
67 void Free() {
delete BaseT::ref_; }
77 using BaseT::operator=;
90 :
public UniquePtrBase<unsigned char, UniquePtr<unsigned char> > {
95 using BaseT::operator=;
107 #ifdef CVMFS_NAMESPACE_GUARD
111 #endif // CVMFS_UTIL_POINTER_H_
DerivedT & operator=(T *ref)
UniquePtr(unsigned char *ref)
UniquePtrBase< T, UniquePtr< T > > BaseT
UniquePtrBase< void, UniquePtr< void > > BaseT
UniquePtrBase< unsigned char, UniquePtr< unsigned char > > BaseT