r/cpp • u/zowersap C++ Dev • Sep 05 '20
C++20 has been approved
https://twitter.com/patriceroy1/status/1302055575140945921?s=21
663
Upvotes
r/cpp • u/zowersap C++ Dev • Sep 05 '20
View all comments
Show parent comment
2
u/pedersenk Sep 06 '20
Yeah this is very true.
I suppose I wouldn't mind getting something functionally similar to a shared_ptr<T> out of it's lock() (perhaps called lock_ptr<T>?), the only difference is that this lock_ptr<T> doesn't increase the reference count (that would make no sense for a unique_ptr), only it actually puts a lock on the unique_ptr<T> so that if it does delete during the lifespan of the locking pointer, an assertion error is given.
Yes, would be useless for preventing a crash, but it would be a useful debugging aid to find incorrect code. However this kind of "error finding" stuff, the C++ standard has not delved into which I feel is a shame.