Jens's latest, following up on his pointers post:
An overview on smart pointers
by Jens Weller
From the article:
So, a smart pointer is only needed, when you use new or other means of dynamic memory allocation. In my opinion, you should prefer to allocate variables on the stack, so when refactoring code (to C++11), you should always ask yourself, if this
new
is needed, or could be replaced with an object on the stack. When you need to usenew
, you should always use a smart pointer in my opinion. Also some smart pointers offer a custom deleter, which is handy if you have an object that is either not allocated bynew
and/or needs to be freed by calling a special function.
Add a Comment
Comments are closed.