C++ Logo

std-discussion

Advanced search

Re: Making the new expression smart

From: Christopher Head <chead_at_[hidden]>
Date: Thu, 17 Sep 2020 12:22:55 -0700
On Thu, 17 Sep 2020 21:13:30 +0200
Richard Hodges via Std-Discussion <std-discussion_at_[hidden]>
wrote:

> In this case, yes. But then so does initialising a shared_ptr with a
> naked pointer, so nothing would be lost.

I think it’s a perspective thing. Today people generally try to avoid
using new because it returns raw pointers, so make_unique and
make_shared are common. I figured the point of changing operator new to
return smart pointers would be to use new more and get away from the
make_foo functions, at which point the double-allocation problem would
arise.
-- 
Christopher Head

Received on 2020-09-17 14:23:00