32 template <
typename Val >
34 __val(v), __refcount(v ? new unsigned int(1U) : 0) {
41 template <
typename Val >
52 template <
typename Val >
53 template <
typename DownVal >
64 template <
typename Val >
80 template <
typename Val >
106 template <
typename Val >
115 Val* old_val =
__val;
125 }
catch (std::bad_alloc&) {
126 if (*old_refcount == 1) {
146 template <
typename Val >
147 template <
typename DownVal >
153 Val* old_val =
__val;
169 template <
typename Val >
178 template <
typename Val >
185 template <
typename Val >
192 template <
typename Val >
201 template <
typename Val >
210 template <
typename Val >
219 template <
typename Val >
226 template <
typename Val >
230 Val* old_val =
__val;
240 template <
typename Val >
249 template <
typename Val >
256 template <
typename Val >
259 Val* tmp_val = ptr2.
__val;
265 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.
Class providing aGrUM's "smart" pointers.
gum is the global namespace for all aGrUM entities
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.