Boost logo

Boost Users :

From: Olivier Tournaire (olitour_at_[hidden])
Date: 2007-05-09 19:37:15


Great, that was it.
Best regards.

Peter Dimov a écrit :
> Olivier Tournaire wrote:
>
>
>> if ( typeid(m_rectangle.get()) == typeid(rectangle*) )
>> {
>> boost::shared_ptr<rectangle> rect(
>> (rectangle*)(m_rectangle.get()) );
>>
>
> This is the cause of your immediate problem. You are creating a second
> shared_ptr to the same raw pointer. This second shared_ptr has no knowledge
> of m_rectangle and will call delete on the raw pointer when it goes out of
> scope. Why not just use m_rectangle inside the if? You don't need the cast
> or the second shared_ptr.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net