C++ Logo


Advanced search

Re: default_new?

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Thu, 24 Nov 2022 19:55:08 +0800
On Thu, 24 Nov 2022 at 01:02, Jason McKesson via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> On Wed, Nov 23, 2022 at 11:26 AM Antony Peacock via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
> >
> > But we do have proposals which include std::default_copy (p0201r6 & p1950r2) which is as close of an analogous use case as I am aware of. Note we use separate types for allocator support in this case.
> Those are not proposals for `default_copy`; they are proposals that
> *include* `default_copy` as part of what they're doing. The copying
> behavior of those types is something that you specify as a parameter.
> But the initial `indirect_value` is always given a pointer to an
> existing object which is adopted, much like `unique_ptr`. You have the
> choice of `make/allocate_indirect_value`, just like `unique_ptr`.
> So what purpose would your hypothetical `default_new` suggestion serve?

Thank you all.

I went the wrong way. My original purpose was to customize some object
manager classes, like the following:

template <typename T,
          typename Creator = default_new<T>,
          typename Deleter = default_delete<T>>
class ObjectManager;

However, thinking again, I really should use this instead:

template <typename T,
          typename Allocator = std::allocator<T>>
class ObjectManager;

Best regards,

Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2022-11-24 11:55:20