[libcxx-commits] [PATCH] D119159: [libc++] Make shared_ptr move unique_ptr's deleter

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 7 11:51:02 PST 2022


philnik added inline comments.


================
Comment at: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp:87
+struct MoveOnlyDeleter {
+  MoveOnlyDeleter() {}
+  MoveOnlyDeleter(MoveOnlyDeleter&&) {}
----------------
ashermancinelli wrote:
> philnik wrote:
> > Could you `= delete` the default constructor? That ensures the deleter is actually moved properly. Also count how many moves have been made and ensure it's exactly one.
> unique_ptr's deleter is constrained by `_EnableIfDeleterDefaultConstructible` so I can't do that iiuc. Would it suffice to have counts for move and default constructors, and assert that each constructor was called the expected number of times?
The constructors where the deleter has to be default-constructible are disabled, but not unique_ptr itself. The `unique_ptr(nullptr_t, deleter_type&&)` and `unique_ptr(pointer, deleter_type&&)` constructors are still available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119159



More information about the libcxx-commits mailing list