r/ProgrammerHumor • • Oct 10 '26

Meme theyAreLovingIt

Post image
2.1k Upvotes

83 comments sorted by

View all comments

Show parent comment

1

u/conundorum Oct 11 '26

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.