35 template <
typename Val >
37 __val(v), __refcount(v ? new unsigned int(1U) : 0) {
44 template <
typename Val >
55 template <
typename Val >
56 template <
typename DownVal >
67 template <
typename Val >
83 template <
typename Val >
109 template <
typename Val >
118 Val* old_val =
__val;
128 }
catch (std::bad_alloc&) {
129 if (*old_refcount == 1) {
149 template <
typename Val >
150 template <
typename DownVal >
156 Val* old_val =
__val;
172 template <
typename Val >
181 template <
typename Val >
188 template <
typename Val >
195 template <
typename Val >
204 template <
typename Val >
213 template <
typename Val >
222 template <
typename Val >
229 template <
typename Val >
233 Val* old_val =
__val;
243 template <
typename Val >
252 template <
typename Val >
259 template <
typename Val >
262 Val* tmp_val = ptr2.
__val;
268 ptr1.
__val = tmp_val;
RefPtr< Val > & operator=(const RefPtr< Val > &from)
Copy operator.
friend class RefPtr
A friend to allow downcastings.
~RefPtr()
Class destructor.
unsigned int * __refCountPtr() const
A function to return the refcount pointer.
Val * operator->() const
Dereferencing operator.
void __destroy(unsigned int *, Val *)
A function to remove the content of the smart pointer, if any.
friend void swap(RefPtr< Val > &, RefPtr< Val > &)
The swap function must access to gum::RefPtr private parts.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Smart pointersaGrUM's smart pointers keep track of the number of times the value they point to is ref...
Val * __val
The dumb pointer encapsulated into the "smart" pointer.
bool operator!=(const RefPtr< Val > &from) const
Checks whether two RefPtr<Val> are smart pointers for different elements.
bool operator==(const RefPtr< Val > &from) const
Checks whether two RefPtr<Val> are smart pointers for the same element.
void clear()
Makes the smart pointer point to 0.
Val & operator*()
Dereferencing operator.
#define GUM_ERROR(type, msg)
unsigned int refCount() const
Returns the number of smart pointer referencing the contained pointer.
unsigned int * __refcount
A reference counter on *val.