From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b30bd69fa8f63cb2 X-Google-Attributes: gid103376,public X-Google-Thread: fc772,b30bd69fa8f63cb2 X-Google-Attributes: gidfc772,public X-Google-ArrivalTime: 2003-06-23 18:57:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!news-out.newsfeeds.com!propagator2-maxim!news-in-maxim.spamkiller.net!usc.edu!rpi!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada,comp.lang.c++.moderated Subject: Re: C bug of the day Date: 23 Jun 2003 21:59:23 -0400 Organization: http://groups.google.com/ Sender: cppmods@netlab.cs.rpi.edu Message-ID: <1ec946d1.0306231720.7cdc32cb@posting.google.com> References: NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: 23 Jun 2003 18:20:08 -0700 X-Submission-Address: c++-submit@netlab.cs.rpi.edu X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUAPvewd0HMCo9UcraBAQESlgH/SZwM7pstm5Wz24DcMJPS05a5BpdMfSvI 2EPPRc1IEfdPuWOQmmfXqT16K9xbCqIFuk6Dh1MSDCw0u1eGUpDpDA== =d/8c Xref: archiver1.google.com comp.lang.ada:39628 comp.lang.c++.moderated:69064 Date: 2003-06-23T21:59:23-04:00 List-Id: tmoran@acm.org wrote in message news:... > >Because of the swap, C++ gets by with one finalization less:-). On the > What if the object is on a linked list with back pointers so that > after the swap the pointers are wrong? In that case, swap wouldn't make any sense. In the C++ STL and Ada95 Charles libraries, the internal nodes of storage only point to other nodes of internal storage -- never to the container object itself. (This also explains why the C++ std::remove algorithm doesn't actually erase the elements in the container. There's no way to erase without modifying the container, but an iterator doesn't know anything about containers, so std::remove can't erase. That's way std::remove is typically immediately followed by ::erase.) >Or if it just contains pointers > to internal parts of itself? Yes, that is how both the STL and Charles libraries are implemented. http://home.earthlink.net/~matthewjheaney/charles/ (I'll have a new release of Charles in the next few days.) Matt [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]