Boost shared_ptr question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Boost shared_ptr question

Threaded View

  1. #1
    Join Date
    Mar 2009

    Boost shared_ptr question

    Hello all,

    I have a class called Wheel, and I created a boost shared_ptr to this class in the following way:

    typedef boost::shared_ptr<Wheel> WheelPtr;
    I also have a vector of these shared_ptr's to Wheels as so:

    vector<WheelPtr> wheels;
    In the wheel class I have a variable called "flat" which is initialized to true.

    I have one thread that keeps iterating through the list looking for flat wheels like so:

    vector<WheelPtr>::iterator it;
    for(it=wheels.begin(); it!=wheels.end();)
           (*it) = WheelPtr(); // set to NULL here
    In another thread I am constantly doing something else to the wheels. What I have noticed is that when I execute the line:

           (*it) = WheelPtr(); // set to NULL here
    in the debugger the handle is 0x00000000. But in my other thread the handle is something else like 0x00104f08.

    Why is the shared_ptr not NULL in the other thread?

    Ellay K.
    Last edited by ekhule; April 18th, 2013 at 08:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center