C++ std::make_unique instead of new delete
C++
std::make_unique()
is a C++14 feature that creates std::unique_ptr
without using
new
and delete
.
std::make_unique()
is a safer and more convenient way to manage memory in C++.
GCC 4.9
circa 2014 added support for std::make_unique()
, along with virtually all modern C++ compilers for several years already.
__cpp_lib_make_unique feature test macro can fence non-essential code if supporting ancient compilers is required.