C++ Logo

std-proposals

Advanced search

Re: Easier make_unique with deleter function

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 24 Aug 2021 02:38:51 +0300
On Tue, 24 Aug 2021 at 02:22, Jason McKesson via Std-Proposals
<std-proposals_at_[hidden]> wrote:

> `make_unique` was not added because it was shorter to type. In a
> pre-C++17 world, you couldn't guarantee that two argument expressions
> in the same function call would not interleave with one another. As
> such, `make_unique<T>(Args)` was a more exception-safe version of
> `unique_ptr<T>(Args)`.
>
> Of course, since C++17 fixed the problem at the language level (the
> argument expressions can happen in any order, but the sub-expressions
> cannot be interleaved), it has become unnecessary.

It has uses that some audiences consider more important than anything
else, such as being
able to avoid using new-expressions to create objects with unique ownership.

Received on 2021-08-23 18:39:05