38 #if __cplusplus >= 201103L 39 #ifdef ICL_USE_STD_SHARED_POINTER_IF_POSSIBLE 40 #define ICL_USE_STD_SHARED_PTR 44 #ifdef ICL_USE_STD_SHARED_PTR 64 #ifdef ICL_USE_STD_SHARED_PTR 66 template<
class T,
class delOp = ArrayDelOp >
69 std::shared_ptr<T> impl;
71 template<
class DerivedT>
85 template<
class DerivedT>
87 impl(ptData, [bOwn](T *t){
if(bOwn) delOp::delete_func(t); }){
92 template<
class DerivedT>
94 impl(std::static_pointer_cast<T,DerivedT>(r.impl)){
99 SmartPtrBase(
const SmartPtrBase<T,delOp> &r): impl(r.impl){}
110 template<
class DerivedT>
111 SmartPtrBase<T,delOp> &
operator=(
const SmartPtrBase<DerivedT,delOp>& r){
119 SmartPtrBase<T,delOp> &
operator=(
const SmartPtrBase<T,delOp>& r){
125 template<
class DerivedT>
126 SmartPtrBase<T,delOp> &
operator=(DerivedT *p){
127 return this->
operator=(SmartPtrBase<T,delOp>(p));
132 return this->
operator=(SmartPtrBase<T,delOp>(p));
148 const T &
operator* ()
const {
return *impl; }
155 T*
get () {
return impl.get(); }
161 const T*
get ()
const {
return impl.get(); }
174 const T *
operator-> ()
const {
return impl.get(); }
178 operator bool()
const {
return (
bool)impl; }
181 int use_count()
const {
return impl.use_count(); }
221 template<
class T,
class delOp = ArrayDelOp >
238 if(
d) delOp::delete_func(
e);
253 template<
class DerivedT>
255 if(r.
e ==
e)
return *
this;
272 template<
class DerivedT>
278 template<
class DerivedT>
299 template<
class DerivedT>
315 template<
class DerivedT>
351 const T*
get ()
const {
return e; }
368 operator bool()
const {
return (
e != 0); }
SmartPtrBase(const SmartPtrBase< T, delOp > &r)
Create a copy of given smart pointer.
Definition: SmartPtrBase.h:286
undocument this line if you encounter any issues!
Definition: Any.h:37
virtual ~DelOpBase()
Definition: SmartPtrBase.h:52
SmartPtrBase< T, delOp > & operator=(T *p)
allows for direct assignment of pointers to a SmartPtr object
Definition: SmartPtrBase.h:321
T * operator->()
returns the currently hold element
Definition: SmartPtrBase.h:358
Pointer delete operation class for the SmartPtr class.
Definition: SmartPtrBase.h:55
Pure Interface class for DelOps.
Definition: SmartPtrBase.h:52
int * c
Definition: SmartPtrBase.h:225
SmartPtrBase(DerivedT *ptData, bool bOwn=true)
ptData is given, reference counter is set to 1
Definition: SmartPtrBase.h:273
void set(T *e, int *c, bool d)
sets e and c
Definition: SmartPtrBase.h:246
SmartPtrBase< T, delOp > & assign(const SmartPtrBase< DerivedT, delOp > &r)
utility assignment method used in the SmartPtrBase assignment operators
Definition: SmartPtrBase.h:254
void setNull()
sets the smart pointer to null
Definition: SmartPtrBase.h:380
virtual ~SmartPtrBase()
decreases the reference counter (cleanup on demand)
Definition: SmartPtrBase.h:326
SmartPtrBase< T, delOp > & operator=(DerivedT *p)
allows for direct assignment of pointers to a SmartPtr object
Definition: SmartPtrBase.h:316
static void delete_func(void *v)
Definition: SmartPtrBase.h:61
static void delete_func(T *t)
Definition: SmartPtrBase.h:58
T * get()
returns the pointer to the data
Definition: SmartPtrBase.h:345
T & operator *()
returns a reference of the currently hold element
Definition: SmartPtrBase.h:332
const T * get() const
returns the pointer to the data (const)
Definition: SmartPtrBase.h:351
void dec()
save reference counter decrement (cleanup on demand)
Definition: SmartPtrBase.h:234
T * e
Definition: SmartPtrBase.h:224
SmartPtrBase(const SmartPtrBase< DerivedT, delOp > &r)
Create a copy of given smart pointer with more general type.
Definition: SmartPtrBase.h:279
Array delete operation class for the SmartPtr class.
Definition: SmartPtrBase.h:58
int use_count() const
current reference count
Definition: SmartPtrBase.h:371
#define ICLASSERT(X)
Definition: Macros.h:135
SmartPtrBase()
e and c will become NULL
Definition: SmartPtrBase.h:268
C-Style delete operation class for the SmartPtr class.
Definition: SmartPtrBase.h:61
SmartPtrBase< T, delOp > & operator=(const SmartPtrBase< T, delOp > &r)
explicit implmentation of the same type assignment operator
Definition: SmartPtrBase.h:309
Base class for reference counting smart-pointers.
Definition: SmartPtrBase.h:222
static void delete_func(T *t)
Definition: SmartPtrBase.h:55
SmartPtrBase< T, delOp > & operator=(const SmartPtrBase< DerivedT, delOp > &r)
sets the pointer to hold another reference
Definition: SmartPtrBase.h:300
bool d
Definition: SmartPtrBase.h:226
void inc()
save reference counter increment
Definition: SmartPtrBase.h:229