[libcxx-commits] [PATCH] D153991: [libc++] explicitly specialises `unique_ptr` when using `default_delete`

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 29 09:50:26 PDT 2023


cjdb added inline comments.


================
Comment at: libcxx/include/__memory/unique_ptr.h:710-712
+#if defined(_LIBCPP_EXACTLY_ONE_DEFAULT_DELETE_PER_TYPE)
+  inline static deleter_type __deleter;
+#else
----------------
ldionne wrote:
> I believe that makes us non-conforming? `get_deleter()` returns a reference to that, so different deleters need to have different addresses. It's a bit pedantic for sure, but this still seems like not what the standard intended us to implement `unique_ptr` as.
> 
> If we get the same (or almost the same) benefits from simply avoiding `__compressed_pair`, I would personally prefer that approach.
The wording says that it needs to return a reference: it doesn't say that it needs to return references to unique objects. Given that this is also for a stateless allocator, I don't think it's non-conforming at all.

Note that I'm pretty committed to trying to get rid of `__compressed_pair`, since that improves the situation for everyone (but happy to debate the conformance matter above, here or elsewhere).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153991/new/

https://reviews.llvm.org/D153991



More information about the libcxx-commits mailing list