Search⌘ K
AI Features

Shared Pointers and Arrays

Explore how C++17 introduces support for managing arrays with std::shared_ptr, allowing safer memory handling for raw pointers in scenarios where standard containers are not feasible. Understand limitations like the lack of std::make_shared for arrays in C++17 and practical cases for shared pointers with arrays.

We'll cover the following...

Before C++17

Only unique_ptr was able to handle arrays out of the box (without the need to define a custom deleter).

After C++17

Now it’s also possible with shared_ptr as shown below:

 ...