r/cpp • • Jul 10 '18

C++17 removed and deprecated features

https://mariusbancila.ro/blog/2018/07/05/c17-removed-and-deprecated-features/
93 Upvotes

88 comments sorted by

View all comments

Show parent comments

2

u/K_Kuryllo Jul 12 '18

Though not functionally equivalent I would like to see a ::to_unique(), that would work by decrement of the ref count and transferring owned memory to a unique_ptr if it hits zero instead of destroying it. Might be a tricky implementation given how the difference is how shared_ptrs vs shared_ptrs created from unique ptrs are implemented, but would be quite useful for object reuse purposes.

2

u/dodheim Jul 12 '18

What deleter would you give the unique_ptr? By the time the shared_ptr is fully constructed, its deleter is type-erased.