C++: Smart pointers, part 5: weak_ptr

This is the last of several posts I wrote related to smart pointers: Smart pointers unique_ptr More on unique_ptr shared_ptr weak_ptr In modern C++ applications (C++11 and later), you can replace almost all your naked pointers to shared_ptr and unique_ptr in order to have automatic resource administration in a deterministic way so you will not… Continue reading C++: Smart pointers, part 5: weak_ptr

Advertisements

C++: Smart pointers, part 4: shared_ptr

This is the fourth post of several posts I wrote related to smart pointers: Smart pointers unique_ptr More on unique_ptr shared_ptr weak_ptr As I mentioned in other posts, C++11 brings a new set of smart pointers into C++. The most useful smart pointer is shared_ptr: Its memory management policy consists in counting the number of… Continue reading C++: Smart pointers, part 4: shared_ptr

C++: Smart pointers, part 3: More on unique_ptr

This is the third post of several posts I wrote related to smart pointers: Smart pointers unique_ptr More on unique_ptr shared_ptr weak_ptr Ok, here I am going to write about two other features that unique_ptr has that I did not mention in my last post. unique_ptr default behavior consists on take ownership of a pointer… Continue reading C++: Smart pointers, part 3: More on unique_ptr

C++11: Smart Pointers, part 2: unique_ptr

This is the second post of several posts I wrote related to smart pointers: Smart pointers unique_ptr More on unique_ptr shared_ptr weak_ptr C++11 ships with a set of out-of-the-box smart pointers that help us to manage the memory easily. One of those smart pointers is the unique_ptr. Consider this piece of code: If you execute… Continue reading C++11: Smart Pointers, part 2: unique_ptr

C++: Smart pointers, part 1

This is the first of several posts I wrote related to smart pointers: Smart pointers unique_ptr More on unique_ptr shared_ptr weak_ptr Memory management in C is too error prone because keeping track of each bunch of bytes allocated and deallocated can be really confusing and stressing. Although C++ has the same manual memory management than… Continue reading C++: Smart pointers, part 1