On 11/10/11 7:20 PM, Szymon Gatner wrote:
Hi,
Why weak_ptr does not have (smart) pointer semantics? No * or -> or even get().
I often need a pointer type that is a listener to shared_ptr<> (does not affect refcount) but is still usable as a regular pointer type. If providing * and -> operators is for some reason undesirable then just a get() member would be nice as it would allow to implement own wrapper with pointer semantics. get() would return raw pointer from shared counter (so is fast) and not shared_ptr<> as lock() does.
I think the issue is that without converting the weak_ptr to a shared_ptr, you don't have any way to make sure that the object pointed to by the weak_ptr hasn't gone away (especially in a multi-threaded application). -- Richard Damon