boost::shared_ptr and stack overflow

Started by
0 comments, last by JohnBolton 16 years, 8 months ago
I converted my program to use boost::shared_ptr instead of normal pointers. I have class with std::vector with shared pointers in it and when I clear the vector I got crash with stack overflow and access violation in the vector. This is my first time using shared pointers in a complex program so it's probably caused by my bad design. I have something like this:

class MyClass
{
    // something
    vector<shared_ptr<AnotherClass>> my_vector;
};

class SecondClass
{
    // something else
    vector<shared_ptr<AnotherClass>> another_vector; // may have same elements with my_vector
};
Is this OK? Or how should I use shared pointers? And if anybody has a good guess what's causing the stack overflow, let me know.
Advertisement
A stack overflow frequently indicates infinite recursion. Look at the call stack. Does the AnotherClass destructor affect the vectors in MyClass or SecondClass?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement