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: Sun, 16 Feb 2025 17:49:59 +0000
  *
Sebastian wrote: I am just thinking, whether the implicitly contained unique_ptr in your solution should/could be made explicit (e.g. as template argument) instead.

If I understand your question, the simple way to make the implicit unique_ptr in notifying_unique_ptr more explicit would be to not use the notifying_unique_ptr using declaration and write what it represents instead. So instead of writing xnr::notifying_unique_ptr<T, D> you would write std::unique_ptr<T, xnr::notify_ptrs<T, D>>. It is more verbose but that also makes it more transparent about what it is. It isn't hard to guess what is going on - a deleter called notify_ptrs. It could also be more reassuring in code reviews to see that trusted std::unique_ptr explicitly visible.



Received on 2025-02-16 17:50:04