What is the difference between these two pieces of code? Are they the same with just a different way of defining?
std::unique_ptr<int> y(newint(20));
and
std::unique_ptr<int> y = std::make_unique<int>(20);
When would you use make_unique over the first example? I'm trying to wrap my head around smart pointers. I've used them plenty, but don't actually understand what they're doing. I guess you could say I've gotten lucky. But I really need to understand this stuff better.
That "unspecified-evaluation-order leak" in JLBorges link is mildly surprising. Basically, since both news can execute before either unique_ptr ctor in the following code, if the first-executed ctor throws, the other new leaks. make_unique prevents this since it does the new iteself.