C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A non-owning but self zeroing smart pointer for single ownership

From: JOHN MORRISON <inglesflamenco_at_[hidden]>
Date: Mon, 17 Feb 2025 11:55:09 +0000
Sebastian wrote: Hi John, you want to introduce a new smart pointer to the language. The existing ones support flexible resources beyond memory with custom deleters. Your smart pointer does not have to, it is your proposal after all,

Hi Sebastian,

Both unique_ptr and shared_ptr provide for custom deleters so they can be used to hold resources other than heap objects. The use of ptr_to_unique doesn't change that. You have added the notify_ptrs deleter to your unique_ptr declaration to enable referencing with ptr_to_unique but that doesn't stop you from using a custom deleter. You simply add it as the second template parameter to notify_ptrs.

std::unique_ptr<T, xnr::notify_ptrs<T, MyDeleter>>

or with the notifying_unique_ptr using declaration.

xnr:: notifying_unique_ptr<T, MyDeleter>


Received on 2025-02-17 11:55:17