1 #ifndef SimTK_SimTKCOMMON_REFERENCE_PTR_H_
2 #define SimTK_SimTKCOMMON_REFERENCE_PTR_H_
71 {
if (&r !=
this)
clear();
return *
this; }
75 {
reset(&t);
return *
this; }
79 {
reset(tp);
return *
this; }
93 operator T*()
const {
return p; }
97 operator bool()
const {
return !
empty(); }
100 T*
get()
const {
return p; }
106 "An attempt was made to dereference a null pointer.");
140 template <
class T>
inline void
147 #endif // SimTK_SimTKCOMMON_REFERENCE_PTR_H_
void swap(ReferencePtr &other)
Swap the contents of this ReferencePtr with another one.
Definition: ReferencePtr.h:122
ReferencePtr & operator=(const ReferencePtr &r)
Copy assignment sets the pointer to null (except for a self-assign); see class comments for why...
Definition: ReferencePtr.h:70
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
~ReferencePtr()
Destructor does nothing.
Definition: ReferencePtr.h:82
void swap(SimTK::ReferencePtr< T > &p1, SimTK::ReferencePtr< T > &p2)
This is a specialization of the STL std::swap() algorithm which uses the cheap built-in swap() member...
Definition: ReferencePtr.h:141
T element_type
Definition: ReferencePtr.h:54
ReferencePtr()
Default constructor creates an empty object.
Definition: ReferencePtr.h:59
T & operator*() const
The "dereference" operator returns a reference to the target object.
Definition: ReferencePtr.h:90
T & getRef() const
Return a reference to the target object.
Definition: ReferencePtr.h:104
ReferencePtr(T &t)
Construct from a reference stores the address of the supplied object.
Definition: ReferencePtr.h:64
ReferencePtr(T *tp)
Construct from a given pointer stores the pointer.
Definition: ReferencePtr.h:61
T * operator->() const
Return the contained pointer.
Definition: ReferencePtr.h:86
T & reference
Definition: ReferencePtr.h:56
T * release()
Extract the pointer from this container, leaving the container empty.
Definition: ReferencePtr.h:116
void reset(T *tp)
Replace the stored pointer with a different one; no destruction occurs.
Definition: ReferencePtr.h:119
ReferencePtr(const ReferencePtr &)
Copy constructor unconditionally sets the pointer to null; see class comments for why...
Definition: ReferencePtr.h:67
#define SimTK_ERRCHK(cond, whereChecked, msg)
Definition: ExceptionMacros.h:324
This is a smart pointer that implements "cross reference" semantics where a pointer data member of so...
Definition: ReferencePtr.h:52
T * pointer
Definition: ReferencePtr.h:55
ReferencePtr & operator=(T &t)
This form of assignment replaces the currently-referenced object by a reference to the source object;...
Definition: ReferencePtr.h:74
ReferencePtr & operator=(T *tp)
This form of assignment replaces the current pointer with the given one; no destruction occurs...
Definition: ReferencePtr.h:78
bool empty() const
Return true if this container is empty.
Definition: ReferencePtr.h:111
void clear()
Make this container empty; no destruction occurs.
Definition: ReferencePtr.h:113