1 #ifndef SimTK_SimTKCOMMON_REFERENCE_PTR_H_ 
    2 #define SimTK_SimTKCOMMON_REFERENCE_PTR_H_ 
   96     {   assert(mustBeZero==0); }
 
  105     {   
if (&src != 
this) 
reset(); 
return *
this; }
 
  118     {  
reset(&t); 
return *
this; }
 
  123     {   
reset(tp); 
return *
this; }
 
  135     T* 
get() const noexcept {
return p;}
 
  141                     "An attempt was made to dereference a null pointer."); 
 
  160     void reset(T* tp=
nullptr) noexcept {p=tp;}
 
  165         std::swap(p, other.p);
 
  169     bool empty() const noexcept {
return !p;}
 
  173     explicit operator bool() const noexcept {
return !
empty();}
 
  189     DEPRECATED_14(
"use get() rather than implicit conversion to T*")
 
  190     operator T*() const noexcept {
return p;}
 
  211 template <
class T> 
inline void 
  219 template <
class charT, 
class traits, 
class T>
 
  220 inline std::basic_ostream<charT,traits>& 
 
  221 operator<<(std::basic_ostream<charT,traits>& os, 
 
  223 {   os << p.
get(); 
return os; }
 
  230 template <
class T, 
class U>
 
  233 {   
return lhs.
get() == rhs.
get(); }
 
  239 {   
return lhs.
empty(); }
 
  245 {   
return rhs.
empty(); }
 
  253 template <
class T, 
class U>
 
  256 {   
return lhs.
get() < rhs.
get(); }
 
  272 {   
return !rhs.
empty(); }
 
  279 template <
class T, 
class U>
 
  282 {   
return !(lhs==rhs); }
 
  288 {   
return !(lhs==
nullptr); }
 
  294 {   
return !(
nullptr==rhs); }
 
  298 template <
class T, 
class U>
 
  301 {   
return rhs < lhs; }
 
  306 {   
return nullptr < lhs; }
 
  312 {   
return rhs < 
nullptr; }
 
  317 template <
class T, 
class U>
 
  320 {   
return !(lhs < rhs); }
 
  325 {   
return !(lhs < 
nullptr); }
 
  331 {   
return !(
nullptr < rhs); }
 
  337 template <
class T, 
class U>
 
  340 {   
return !(rhs < lhs); }
 
  346 {   
return !(
nullptr < lhs); }
 
  352 {   
return !(rhs < 
nullptr); }
 
  360 {   assert(mustBeZero==0); 
return !(lhs==
nullptr); }
 
#define SimTK_ERRCHK(cond, whereChecked, msg)
Definition: ExceptionMacros.h:324
 
Mandatory first inclusion for any Simbody source or header file.
 
#define DEPRECATED_14(MSG)
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:289
 
This is a smart pointer that implements "cross reference" semantics where a pointer data member of so...
Definition: ReferencePtr.h:60
 
void reset(T *tp=nullptr) noexcept
Replace the stored pointer with a different one; no destruction occurs.
Definition: ReferencePtr.h:160
 
bool operator>=(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Pointer greater-or-equal test defined as !(lhs < rhs).
Definition: ReferencePtr.h:318
 
bool operator<(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Less-than operator for two compatible ReferencePtr containers, comparing the pointers,...
Definition: ReferencePtr.h:254
 
bool operator>(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Pointer greater-than test defined as rhs < lhs.
Definition: ReferencePtr.h:299
 
bool operator<(const ReferencePtr< T > &lhs, std::nullptr_t)
Less-than comparison against a nullptr.
Definition: ReferencePtr.h:263
 
ReferencePtr & operator=(T *tp) noexcept
This form of assignment replaces the current pointer with the given one; no destruction occurs.
Definition: ReferencePtr.h:122
 
T * get() const noexcept
Return the contained pointer, or null if the container is empty.
Definition: ReferencePtr.h:135
 
bool operator<(std::nullptr_t, const ReferencePtr< T > &rhs)
Less-than comparison of a nullptr against this container.
Definition: ReferencePtr.h:271
 
ReferencePtr(T *tp) noexcept
Construct from a given pointer stores the pointer.
Definition: ReferencePtr.h:77
 
ReferencePtr(T &t) noexcept
Construct from a reference stores the address of the supplied object.
Definition: ReferencePtr.h:81
 
bool operator==(const ReferencePtr< T > &lhs, std::nullptr_t)
Comparison against nullptr; same as lhs.empty().
Definition: ReferencePtr.h:238
 
bool operator!=(const ReferencePtr< T > &lhs, std::nullptr_t)
nullptr inequality test defined as !(lhs==nullptr).
Definition: ReferencePtr.h:287
 
T * release() noexcept
Extract the pointer from this container, leaving the container empty.
Definition: ReferencePtr.h:177
 
bool operator<=(const ReferencePtr< T > &lhs, std::nullptr_t)
nullptr less-or-equal test defined as !(nullptr < lhs) (note reversed arguments).
Definition: ReferencePtr.h:345
 
void clear() noexcept
(Deprecated) Use reset() instead.
Definition: ReferencePtr.h:185
 
bool operator!=(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Pointer inequality test defined as !(lhs==rhs).
Definition: ReferencePtr.h:280
 
ReferencePtr(std::nullptr_t) noexcept
Constructor from nullptr is the same as the default constructor.
Definition: ReferencePtr.h:74
 
bool operator>=(const ReferencePtr< T > &lhs, std::nullptr_t)
nullptr greater-or-equal test defined as !(lhs < nullptr).
Definition: ReferencePtr.h:324
 
T & operator*() const
The "dereference" operator returns a reference to the target object.
Definition: ReferencePtr.h:151
 
bool operator!=(std::nullptr_t, const ReferencePtr< T > &rhs)
nullptr inequality test defined as !(nullptr==rhs).
Definition: ReferencePtr.h:293
 
bool operator>(std::nullptr_t, const ReferencePtr< T > &rhs)
nullptr greater-than test defined as rhs < nullptr.
Definition: ReferencePtr.h:311
 
bool operator>=(std::nullptr_t, const ReferencePtr< T > &rhs)
nullptr greater-or-equal test defined as !(nullptr < rhs).
Definition: ReferencePtr.h:330
 
~ReferencePtr() noexcept
Destructor does nothing.
Definition: ReferencePtr.h:128
 
void swap(ReferencePtr &other) noexcept
Swap the contents of this ReferencePtr with another one.
Definition: ReferencePtr.h:164
 
bool operator==(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Compare for equality the managed pointers contained in two compatible ReferencePtr containers.
Definition: ReferencePtr.h:231
 
T & reference
Type of a reference to the contained object.
Definition: ReferencePtr.h:64
 
bool operator>(const ReferencePtr< T > &lhs, std::nullptr_t)
nullptr greater-than test defined as nullptr < lhs.
Definition: ReferencePtr.h:305
 
ReferencePtr(ReferencePtr &&src) noexcept
Move constructor copies the pointer from the source and leaves the source empty.
Definition: ReferencePtr.h:89
 
T & getRef() const
Return a reference to the target object.
Definition: ReferencePtr.h:139
 
bool operator<=(const ReferencePtr< T > &lhs, const ReferencePtr< U > &rhs)
Pointer less-or-equal test defined as !(rhs < lhs) (note reversed arguments).
Definition: ReferencePtr.h:338
 
ReferencePtr(const ReferencePtr &) noexcept
Copy constructor unconditionally sets the pointer to null; see class comments for why.
Definition: ReferencePtr.h:85
 
T * operator->() const
Return the contained pointer.
Definition: ReferencePtr.h:147
 
ReferencePtr & operator=(ReferencePtr &&src) noexcept
Move assignment copies the pointer from the source and leaves the source empty.
Definition: ReferencePtr.h:109
 
T element_type
Type of the contained object.
Definition: ReferencePtr.h:62
 
ReferencePtr & operator=(T &t) noexcept
This form of assignment replaces the currently-referenced object by a reference to the source object;...
Definition: ReferencePtr.h:117
 
ReferencePtr() noexcept
Default constructor creates an empty object.
Definition: ReferencePtr.h:69
 
bool empty() const noexcept
Return true if this container is empty.
Definition: ReferencePtr.h:169
 
ReferencePtr & operator=(const ReferencePtr &src) noexcept
Copy assignment sets the pointer to nullptr (except for a self-assign); see class comments for why.
Definition: ReferencePtr.h:104
 
bool operator<=(std::nullptr_t, const ReferencePtr< T > &rhs)
nullptr less-or-equal test defined as !(rhs < nullptr) (note reversed arguments).
Definition: ReferencePtr.h:351
 
bool operator==(std::nullptr_t, const ReferencePtr< T > &rhs)
Comparison against nullptr; same as rhs.empty().
Definition: ReferencePtr.h:244
 
T * pointer
Type of a pointer to the contained object.
Definition: ReferencePtr.h:63
 
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
 
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387