Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Removing elements (object pointers) from a std::list without destroying them?

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Feb 2011 16:51
Like the title says, is this possible?
What I want to do is be able to remove a object reference from a list without the list's methods for doing so automatically calling the stored object's destructor.
Is there a way, maybe using a different list implementation, or do I have to resort to writing my own list class?
If so, is there any particular reason why you are not expected to be able to just remove something's reference from being present in a list?


"Why do programmers get Halloween and Christmas mixed up?"
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 25th Feb 2011 17:31
So you want to remove an element from a list without it calling the destructor? I suppose you could make a list of pointers, and it will just remove the pointer.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Feb 2011 23:13
Actually, pointers is what I have in there. If it were the actual objects it would've made a lot more sense to have them deleted


"Why do programmers get Halloween and Christmas mixed up?"
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 26th Feb 2011 07:37 Edited at: 26th Feb 2011 07:38
Could you post the code? If you have a list of pointers, removing a pointer from a list shouldn't destroy the original object.

Login to post a reply

Server time is: 2024-11-19 12:21:38
Your offset time is: 2024-11-19 12:21:38