CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
mayown_ptr< T, N > Class Template Reference

#include <mayown_ptr.h>

Public Member Functions

bool empty () const
 
T const * get () const
 
bool isOwn () const
 
 mayown_ptr (T *ip=nullptr)
 
 mayown_ptr (T const &ip)
 
 mayown_ptr (mayown_ptr &)=delete
 
 mayown_ptr (mayown_ptr &&rh)
 
T const & operator* () const
 
T const * operator-> () const
 
mayown_ptroperator= (mayown_ptr &)=delete
 
mayown_ptroperator= (mayown_ptr &&rh)
 
T const * raw () const
 
T const * release ()
 
void reset ()
 
void reset (T *ip)
 
void reset (T const &ip)
 
 ~mayown_ptr ()
 

Private Member Functions

void destroy ()
 
void markOwn ()
 
T const * pointer () const
 

Private Attributes

T const * p =nullptr
 

Detailed Description

template<typename T, int N = sizeof(T*)>
class mayown_ptr< T, N >

Definition at line 13 of file mayown_ptr.h.

Constructor & Destructor Documentation

template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( T ip = nullptr)
inlineexplicit

Definition at line 43 of file mayown_ptr.h.

References mayown_ptr< T, N >::markOwn().

Referenced by mayown_ptr< T, N >::~mayown_ptr().

43 : p(ip) { markOwn();}
void markOwn()
Definition: mayown_ptr.h:17
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( T const &  ip)
inlineexplicit

Definition at line 44 of file mayown_ptr.h.

44 : p(&ip) {}
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::~mayown_ptr ( )
inline

Definition at line 45 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), and mayown_ptr< T, N >::mayown_ptr().

45 { destroy();}
void destroy()
Definition: mayown_ptr.h:39
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( mayown_ptr< T, N > &  )
delete
template<typename T, int N = sizeof(T*)>
mayown_ptr< T, N >::mayown_ptr ( mayown_ptr< T, N > &&  rh)
inline

Definition at line 47 of file mayown_ptr.h.

References mayown_ptr< T, N >::operator=().

47 : p(rh.p) { rh.p=nullptr;}
T const * p
Definition: mayown_ptr.h:15

Member Function Documentation

template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::destroy ( )
inlineprivate

Definition at line 39 of file mayown_ptr.h.

References mayown_ptr< T, N >::isOwn(), and mayown_ptr< T, N >::pointer().

Referenced by mayown_ptr< T, N >::operator=(), mayown_ptr< T, N >::reset(), and mayown_ptr< T, N >::~mayown_ptr().

39  {
40  if (isOwn()) delete const_cast<T*>(pointer());
41  }
bool isOwn() const
Definition: mayown_ptr.h:25
T const * pointer() const
Definition: mayown_ptr.h:30
long double T
template<typename T, int N = sizeof(T*)>
bool mayown_ptr< T, N >::empty ( ) const
inline
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::get ( ) const
inline
template<typename T, int N = sizeof(T*)>
bool mayown_ptr< T, N >::isOwn ( ) const
inline

Definition at line 25 of file mayown_ptr.h.

References N.

Referenced by mayown_ptr< T, N >::destroy(), and MultiHitGeneratorFromChi2::hitSets().

25  {
26  unsigned char buff[N]; memcpy(buff,&p,N);
27  return 1==(buff[N-1]&1);
28  }
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::markOwn ( )
inlineprivate

Definition at line 17 of file mayown_ptr.h.

References N.

Referenced by mayown_ptr< T, N >::mayown_ptr(), and mayown_ptr< T, N >::reset().

17  {
18  if (nullptr==p) return;
19  unsigned char buff[N]; memcpy(buff,&p,N);
20  assert((buff[N-1]&1)==0);
21  ++buff[N-1];
22  memcpy(&p,buff,N);
23  }
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const& mayown_ptr< T, N >::operator* ( void  ) const
inline

Definition at line 51 of file mayown_ptr.h.

References mayown_ptr< T, N >::pointer().

51 { return *pointer();}
T const * pointer() const
Definition: mayown_ptr.h:30
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::operator-> ( ) const
inline

Definition at line 52 of file mayown_ptr.h.

References mayown_ptr< T, N >::pointer().

52 { return pointer();}
T const * pointer() const
Definition: mayown_ptr.h:30
template<typename T, int N = sizeof(T*)>
mayown_ptr& mayown_ptr< T, N >::operator= ( mayown_ptr< T, N > &  )
delete
template<typename T, int N = sizeof(T*)>
mayown_ptr& mayown_ptr< T, N >::operator= ( mayown_ptr< T, N > &&  rh)
inline

Definition at line 49 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy().

49 { destroy(); p=rh.p; rh.p=nullptr; return *this;}
void destroy()
Definition: mayown_ptr.h:39
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::pointer ( ) const
inlineprivate

Definition at line 30 of file mayown_ptr.h.

References N, and np.

Referenced by mayown_ptr< T, N >::destroy(), mayown_ptr< T, N >::get(), mayown_ptr< T, N >::operator*(), mayown_ptr< T, N >::operator->(), and mayown_ptr< T, N >::release().

30  {
31  unsigned char buff[N]; memcpy(buff,&p,N);
32  buff[N-1] &= 0xFE;
33  assert((buff[N-1]&1)==0);
34  T const * np;
35  memcpy(&np,buff,N);
36  return np;
37  }
int np
Definition: AMPTWrapper.h:33
#define N
Definition: blowfish.cc:9
T const * p
Definition: mayown_ptr.h:15
long double T
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::raw ( ) const
inline

Definition at line 60 of file mayown_ptr.h.

References mayown_ptr< T, N >::p.

Referenced by operator==().

60 { return p;}
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::release ( )
inline

Definition at line 54 of file mayown_ptr.h.

References np, and mayown_ptr< T, N >::pointer().

Referenced by MultiHitGeneratorFromChi2::hitSets().

54 { auto np=pointer(); p=nullptr; return np;}
int np
Definition: AMPTWrapper.h:33
T const * p
Definition: mayown_ptr.h:15
T const * pointer() const
Definition: mayown_ptr.h:30
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( void  )
inline

Definition at line 55 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy().

Referenced by MultiHitGeneratorFromChi2::hitSets().

55 { destroy(); p=nullptr;}
void destroy()
Definition: mayown_ptr.h:39
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T ip)
inline

Definition at line 56 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy(), and mayown_ptr< T, N >::markOwn().

56 { destroy(); p=ip; markOwn();}
void markOwn()
Definition: mayown_ptr.h:17
void destroy()
Definition: mayown_ptr.h:39
T const * p
Definition: mayown_ptr.h:15
template<typename T, int N = sizeof(T*)>
void mayown_ptr< T, N >::reset ( T const &  ip)
inline

Definition at line 57 of file mayown_ptr.h.

References mayown_ptr< T, N >::destroy().

57 { destroy(); p=&ip;}
void destroy()
Definition: mayown_ptr.h:39
T const * p
Definition: mayown_ptr.h:15

Member Data Documentation

template<typename T, int N = sizeof(T*)>
T const* mayown_ptr< T, N >::p =nullptr
private