News for hackers. Stuff that matters.
Re:Why the C++ standard ships every three years by jdsully on Saturday July 13, 2019 @08:35PM (#20430960)
Careful with that if it's not the only thing happening in the statement. It might be a while between the 'new' and the unique_ptr ctor. If an exception happens in between the object will leak.

e.g. foo(unique_ptr<X>(new X), unique_ptr<Y>(new Y)) is a leak waiting to happen.

https://stackoverflow.com/questions/37514509/advantages-of-u...

Re:Why the C++ standard ships every three years by nemanjaboric on Sunday July 14, 2019 @04:30PM (#20435788)
Re:Why the C++ standard ships every three years by TFortunato on Saturday July 13, 2019 @09:18PM (#20431097)
Very good point! I was only thinking about the specific case of a statement that just makes an object and shoves it into a unique_ptr (e.g. does what make_unique does in the linked Herb Sutter article), in response to the comment about not being able too use a normal constructor. You are totally right that this isn't exception safe in cases like you mentioned.