Browse - Programming Tips - Convert a unique_pointer to a shared_pointer

Date: 2018jul25
Language: C/C++

Q.  Convert a unique_pointer to a shared_pointer

A.

auto unique = std::make_unique<std::string>("test"); std::shared_ptr<std::string> shared = std::move(unique);
Source https://ds9a.nl/articles/posts/cpp-5/