![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
RefPtr are a replacement for the usual pointers: they keep track of the number of "smart" pointers pointing to a given element. More...
Classes | |
| class | gum::RefPtr< Val > |
| Smart pointers. More... | |
Functions | |
| template<typename Val> | |
| void | gum::swap (RefPtr< Val > &ptr1, RefPtr< Val > &ptr2) |
| Swap the contents of two RefPtr. | |
RefPtr are a replacement for the usual pointers: they keep track of the number of "smart" pointers pointing to a given element.
When an element is no more referenced by any smart pointer, it is deleted. Hence using RefPtr, developers do not have to worry anymore about memory leaks. The correct way to use RefPtr is by creating unnamed temporaries like:
In any case, if you decide to pass a named pointer as argument to a RefPtr, make sure you will do it only once, that it is allocated on the heap and that you never try to deallocate it yourself, else your program will crash.
Swap the contents of two RefPtr.
The swap function must access to gum::RefPtr private parts.
Definition at line 269 of file refPtr_tpl.h.