0
Where make_unique is better than unique_ptr(raw pointer)
Hi If both (unique_ptr and make_unique) have same output like i have in this code, what's the advantage of make_unique. https://sololearn.com/compiler-playground/cnxp9hb8AB1E/?ref=app
3 ответов
+ 2
make_unique is a fundamental improvement for modern C++ development and it provides:
Crucial exception safety guarantees.
More concise and readable code.
Reduced redundancy.
Potential minor performance benefits.
+ 1
reading a reddit topic similar to this question gave me this link as to why make_unique was added later than make_shared:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3588.htm
+ 1
Let's add the cppreference document
https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique