Exception safety and make_unique
问题 Just to clarify, using make_unique only adds exception safety when you have multiple allocations in an expression, not just one, correct? For example void f(T*); f(new T); is perfectly exception safe (as far as allocations and stuff), while void f(T*, T*); f(new T, new T); is not, correct? 回答1: Not only when you have multiple allocations, but whenever you can throw at different places. Consider this: f(make_unique<T>(), function_that_can_throw()); Versus: f(unique_ptr<T>(new T), function_that