auto_ptr is very bad for stl containers.
http://www.devx.com/tips/Tip/5480
I think one of the boost smart pointers should work.
I thought STL containers destroyed there contents
no because you cant have them in a vector.
edit: auto_ptr that is
[edited by - Eriond on May 30, 2004 8:47:14 PM]
edit: auto_ptr that is
[edited by - Eriond on May 30, 2004 8:47:14 PM]
A plethora of informationt to digest. Thanx for all the informative replies. I''m really just looking for a solution where I can have an expandable type of array that holds pointers to objects. I didn''t want to have to write a Linked List. But since where I need this code will be called a 20-50 times in every main loop iteration, I believe a vector of boost::shared_ptr will be too slow. I think i''ll have to end up using a Singlely linked list :[
template <class Seq>void tidy(Seq& container){ typename container::iterator it; for (it = container.begin(); it != container.end(); ++it) { delete *it; *it = 0; }}tidy(vlpA); // boom
[edited by - fallenang3l on May 30, 2004 9:06:54 PM]
not to evangelize the act of reinventing the wheel, but writing a linked list is a good exercise
... and besides, once you write it you can use it in any application you make in the future! and you''ll know exactly what it does
... and besides, once you write it you can use it in any application you make in the future! and you''ll know exactly what it does
I dug this up on google, it may have a good solution.
http://www.infrasoft.co.at/hn/stlcont.htm
http://www.infrasoft.co.at/hn/stlcont.htm
I don''t think there will be much difference in speed between a vector of ordinary pointers and one of shared_ptr''s. Why not try it? If it''s too slow then you change it.
quote:Original post by xorjesus
I''m really just looking for a solution where I can have an expandable type of array that holds pointers to objects.
java.util....never mind
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement