Reassign unique_ptr object with make_unique statements - Memory leak?
问题 I don't get what following statement would do (specially second line)? auto buff = std::make_unique<int[]>(128); buff = std::make_unique<int[]>(512); Will the second call to make_unique followed by assignment operator will de-allocate memory allocated by first call, or will there be memory leak? Must I have to use buff.reset(new int[512]); ? I've debugged it, but didn't find any operator= being called, nor any destructor be invoked (by unique_ptr ). 回答1: gcc 5.3: #include <memory> extern void