Go to the documentation of this file.
41 #ifndef __BASE_REFCNT_HH__
42 #define __BASE_REFCNT_HH__
44 #include <type_traits>
126 static constexpr
auto TisConst = std::is_const<T>::value;
202 template <
bool B = TisConst>
221 template <
bool B = TisConst>
250 operator bool()
const {
return data != 0; }
256 {
return l.get() ==
r.get(); }
262 {
return l.get() ==
r; }
268 {
return l ==
r.get(); }
273 {
return l.get() !=
r.get(); }
279 {
return l.get() !=
r; }
285 {
return l !=
r.get(); }
287 #endif // __BASE_REFCNT_HH__
RefCounted()
We initialize the reference count to zero and the first object to take ownership of it must increment...
RefCountingPtr()
Create an empty reference counting pointer.
const RefCountingPtr & operator=(RefCountingPtr &&r)
Move-assign the pointer from another RefCountingPtr.
typename std::conditional< TisConst, RefCountingPtr< MinorDynInst >, RefCountingPtr< typename std::add_const< MinorDynInst >::type > >::type ConstT
const RefCountingPtr & operator=(T *p)
Assign a new value to the pointer.
RefCountingPtr(T *data)
Create a new reference counting pointer to some object (probably something newly created).
RefCounted & operator=(const RefCounted &)
void set(T *d)
Drop the old reference and change it to something new.
RefCountingPtr(const NonConstT &r)
~RefCountingPtr()
Destroy the pointer and any reference it may hold.
void incref() const
Increment the reference count.
virtual ~RefCounted()
We make the destructor virtual because we're likely to have virtual functions on reference counted ob...
RefCountingPtr(RefCountingPtr &&r)
Move-constructor.
T & operator*() const
Dereference the pointer.
const RefCountingPtr & operator=(const RefCountingPtr &r)
Copy the pointer from another RefCountingPtr.
void del()
Delete the reference to any existing object if it is non NULL.
void decref() const
Decrement the reference count and destroy the object if all references are gone.
RefCountingPtr(const RefCountingPtr &r)
Create a new reference counting pointer by copying another one.
typename std::conditional< TisConst, RefCountingPtr< typename std::remove_const< MinorDynInst >::type >, RefCountingPtr< MinorDynInst > >::type NonConstT
T * operator->() const
Access a member variable.
Derive from RefCounted if you want to enable reference counting of this class.
bool operator!() const
Check if the pointer is empty.
void copy(T *d)
Copy a new pointer value and increment the reference count if it is a valid pointer.
bool operator!=(const RefCountingPtr< T > &l, const RefCountingPtr< T > &r)
Check for inequality of two reference counting pointers.
bool operator==(const RefCountingPtr< T > &l, const RefCountingPtr< T > &r)
Check for equality of two reference counting pointers.
static constexpr auto TisConst
Convenience aliases for const/non-const versions of T w/ friendship.
If you want a reference counting pointer to a mutable object, create it like this:
T * data
The stored pointer.
T * get() const
Directly access the pointer itself without taking a reference.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17