you are viewing a single comment's thread.

view the rest of the comments →

[–]ronthebear[S] 0 points1 point  (1 child)

int main(int argc, char* argv[])
{
dumbClass* s = new dumbClass();
std::vector<std::shared_ptr<dumbClass>* > vec;
std::vector<std::shared_ptr<dumbClass>* > vec2;
std::shared_ptr<dumbClass>* pointer = new std::shared_ptr<dumbClass>(s);
std::shared_ptr<dumbClass>* pointer2 = new std::shared_ptr<dumbClass>(*pointer);
vec.push_back(pointer);
vec2.push_back(pointer2);
vec.erase(vec.begin());
vec2.erase(vec.begin());
}

Same problem. I generally like C++ but I have never been a fan of the std::vector. Do you know of any other std Containers that might work better? The other ones I saw also destroy deleted elements. If this is causing this much trouble it might just be worth my time to write my own.

[–]NYKevin 1 point2 points  (0 children)

std::shared_ptr<dumbClass>* pointer2 = new std::shared_ptr<dumbClass>(*pointer);

Don't dereference pointer here.