Related to Same address, multiple shared_ptr counters, is it forbidden by C++ standard? and myriad other questions around multiple shared_ptr objects pointing to the same object but not sharing the underlying ref count structure.
What happens if the object inherits from "enable_shared_from_this" in the above mentioned question? What does my shared_from_this() return? One with the custom deleter or the one without?
struct B : boost::enable_shared_from_this<B> {
boost::weak_ptr < B > get_weak() {
return shared_from_this();
}
};
void doNothing(B *) {
}
int main() {
B * b0 = new B;
boost::shared_ptr < B > sddb0(b0, doNothing);
boost::weak_ptr < B > swddb0(sddb0->get_weak());
// Does this have a custom deleter???
boost::shared_ptr < B > sddb1 = swddb0.lock();
boost::shared_ptr < B > scdb0(b0);
boost::weak_ptr < B > swcdb0(sddb0->get_weak());
// Does this *not* have a custom deleter???
boost::shared_ptr < B > scdb1 = swcdb0.lock();
}