$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] shared_ptr design question
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2011-09-16 14:11:31
I'm wondering why there is not an efficient built-in way to check whether two things (e.g.
a shared_ptr and a weak_ptr, but any combination should work) refer to the same object.
In my implementation, I found that a handy thing to have.
In changing code that uses a different home-brew smart pointer, I have to achieve this.
The only way I see is to first resolve the weak pointer, and then compare the get() from
each. That needlessly yoyo's the reference count, which is a horribly expensive atomic
operation.
I find that in the new C++ standard it refers to a owner_before ordering function, which
is a bit more obscure than just comparing the pointers. So I'm wondering why this is not
provided. Is there some reason why the feature is obscured, for portability?
âJohn