Boost logo

Boost Users :

From: Olivier Tournaire (olitour_at_[hidden])
Date: 2007-05-08 10:41:07


Hi all,

I am trying to use shared_ptr in my code, but, I encoutered some problems.
Here is a piece of my code :

The main :

boost::shared_ptr<OGRRectangle> rect( new OGRRectangle(5.,TPoint2D
<double>(50.,20.),0.1325) );
boost::shared_ptr< rectangle_with_profile<OGRRectangle> > r( new
rectangle_with_profile<OGRRectangle> ( rect , 5 , 12 , 1.5 , EXTREME) );

The rectangle_with_profile<T> constructor :

template <class Rect_class>
rectangle_with_profile<Rect_class>::rectangle_with_profile(
boost::shared_ptr<Rect_class> rect , const unsigned int &nb_profiles , const
unsigned int &nb_points , const double &distance , const eProfilePosition
&position=CENTER )
{
    m_rectangle = rect;
   // ...
   // ...
}

Just after the line
boost::shared_ptr< rectangle_with_profile<OGRRectangle> > r( new
rectangle_with_profile<OGRRectangle> ( rect , 5 , 12 , 1.5 , EXTREME) );
the rect<T> destructor is called, and the m_rectangle in
rectangle_with_profile handles a deleted pointer ...

What am I missing ?

Thanks in advance for your help.

-- 
Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux.
Courage.


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