dynamic_cast with WeakPtr?

Hi @all Maybe you can help me. I tried to use weak_ptr for breaking circular references, but I found out that this pointers can't handle derived classes. But in my classes I have some neighbor relations that I want to tore with shared_ptr: class Base { public: boost::shared_ptr<Base> neigh; }; class Derived : public Base { }; int main() { { boost::shared_ptr<Base> a(new Base); boost::shared_ptr<Derived> d(new Derived) a.neigh = d; d.neigh = a; } //both objects are in memory because of circular references, but weak pointer doesn't work, //becaus eit seems to be unable handling derived classes... and there's no dynamic cast } How do you solve problems like that with boost pointers avoiding circular references? Best reagrds, SirAnn
participants (1)
-
Sören Freudiger