C++ Arrays and make_unique
问题 As a follow up to this post I wonder how its implementation of make_unique plays with allocating function-temporary buffer arrays such as in the following code. f() { auto buf = new int[n]; // temporary buffer // use buf ... delete [] buf; } Can this be replaced with some call to make_unique and will the [] -version of delete be used then? 回答1: Here is another solution (in addition to Mike's): #include <type_traits> #include <utility> #include <memory> template <class T, class ...Args>