![]() |
aGrUM 3.1.1
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.
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.