As of... C++17, I believe, unique_ptr can actually handle new just fine now, and (IIRC) it turns out that there are a few cases where this is sometimes better than make_unique():
std::unique_ptr<T> t(new T(...));
You still don't need to worry about the delete because of the smart pointer, and I remember reading that there are a couple uncommon quirks that can sometimes get sidestepped this way.
View all comments
Show parent comment
1
u/conundorum Oct 11 '26
As of... C++17, I believe,
unique_ptrcan actually handlenewjust fine now, and (IIRC) it turns out that there are a few cases where this is sometimes better thanmake_unique():You still don't need to worry about the
deletebecause of the smart pointer, and I remember reading that there are a couple uncommon quirks that can sometimes get sidestepped this way.