MudBytes
» MUDBytes Community » Language Discussions » C and C++ » Uhhelpful GDB...
Pages: << prev 1, 2 next >>
Uhhelpful GDB...
Kayle
Wizard






Group: Members
Posts: 979
Joined: Nov 27, 2006

Go to the bottom of the page Go to the top of the page
#16 Posted Oct 28, 2009, 4:46 pm

Yeah, Baby steps. std::string and the like are not something that's particularly friendly to stuff into Diku if I recall correctly from when Samson did it for AFKMud.
.........................
Owner/Coder                                                            Coder
Malevolent Whispers                                                  Star Wars: The Sith Wars
{Development Phase - Not accepting players}            Open Alpha - Players Welcome - Full System Re-writes Imminent.
IMC2 Contact: Kayle@MW                                       

FUSS Project Team Lead
SmaugMuds.Org - The Smaug MUDs Community Center

David Haley
Wizard






Group: Members
Posts: 5,730
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#17 Posted Oct 28, 2009, 4:58 pm

Indeed, it's not an easy conversion. My policy is to not go in and convert everything, but instead when I add new fields, to use the string classes.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Runter
Wizard






Group: Members
Posts: 1,074
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#18 Posted Oct 29, 2009, 5:38 am


David Haley said:
Indeed, it's not an easy conversion. My policy is to not go in and convert everything, but instead when I add new fields, to use the string classes.


That's precisely what I have done in the past.  Not much extra work either.
.........................
-Heath

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

Kaz
Fledgling




Group: Members
Posts: 5
Joined: Oct 31, 2009

Go to the bottom of the page Go to the top of the page
#19 Posted Oct 31, 2009, 4:44 am

I gave a longer e-mail to Kayle because I had some registration problems, but thought I'd post for the benefit of all anyway.

I think the problem is that remove() doesn't remove() - it just moves all elements with a certain pattern to the end of the list and returns an iterator to the first (re)moved element.  So, by iterating through the list, deleting each and then moving it to the end, you're eventually going to delete one of the elements you removed.

In this case, either erase() should be used (careful, because it invalidates the current iterator and returns a valid iterator to the next element) or just delete them and leave them because it's a destructor and the list will clean itself up.

David Haley
Wizard






Group: Members
Posts: 5,730
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#20 Posted Oct 31, 2009, 4:20 pm

Actually, in this case, list.remove() does in fact remove. You're thinking about the global std::remove function. See also the std::list.remove documentation.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Kaz
Fledgling




Group: Members
Posts: 5
Joined: Oct 31, 2009

Go to the bottom of the page Go to the top of the page
#21 Posted Oct 31, 2009, 5:40 pm

Hmm.  Right you are.  It does invalidate the iterator, however.

David Haley
Wizard






Group: Members
Posts: 5,730
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#22 Posted Oct 31, 2009, 8:10 pm

Yes, you are quite right that you don't want to modify the container as you are iterating over it. In this case, we don't even have to remove things from the container, because the container is about to be destroyed anyhow.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Pages:<< prev 1, 2 next >>

Valid XHTML 1.1! Valid CSS!