1 #ifndef SimTK_SimTKCOMMON_CLONE_PTR_H_
2 #define SimTK_SimTKCOMMON_CLONE_PTR_H_
57 explicit ClonePtr(T** obj) : p(*obj) { *obj=0; }
63 explicit ClonePtr(
const T* obj) : p(obj?obj->clone():0) { }
68 explicit ClonePtr(
const T& obj) : p(&obj?obj.clone():0) { }
79 {
reset(c.p?c.p->clone():0);
return *
this; }
84 {
reset(&t ? t.clone() :0);
return *
this; }
89 {
reset(tp);
return *
this; }
99 if (p == other.p)
return true;
112 if (p == other.p)
return false;
113 if (
empty())
return true;
114 if (other.
empty())
return false;
142 operator const T&()
const {
return getRef(); }
149 operator bool()
const {
return !
empty(); }
163 "An attempt was made to dereference a null pointer.");
171 "An attempt was made to dereference a null pointer.");
188 void reset(T* tp) {
if (tp!=p) {
delete p; p=tp;} }
195 if (*tpp!=p) {
delete p; p=*tpp;}
218 template <
class T>
inline void
225 #endif // SimTK_SimTKCOMMON_CLONE_PTR_H_