Topic: Issue 41
Author: "James Russell Kuyper Jr." <kuyper@wizard.net>
Date: Sat, 3 Aug 2002 19:04:04 GMT Raw View
Allan W wrote:
>
> Defect Report 51 (at
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#51 )
> discusses the operation of list<>::sort(). The proposed resolution
> says to add this text at the end of paragraph 23.1:
>
> > Unless otherwise specified (either explicitly or by defining a
> > function in terms of other functions), invoking a container
> > member function or passing a container as an argument to a
> > library function shall not invalidate iterators to, or change
> > the values of, objects within that container.
>
> Doesn't this imply that sort() cannot change the order of the
> elements? (Which would, of course, make it useless.)
I don't see that. Why would sort() need to invalidate list<> iterators,
or change the values of the objects? The work of sort() would be done
entirely by changing the next_node and prev_node pointers in the linked
list. That doesn't invalidate any iterator, nor change any of the
contained objects. It changes the nodes, but the nodes manage the
objects, they aren't the objects themselves.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Allan_W@my-dejanews.com (Allan W)
Date: Tue, 30 Jul 2002 23:55:15 GMT Raw View
Defect Report 51 (at
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#51 )
discusses the operation of list<>::sort(). The proposed resolution
says to add this text at the end of paragraph 23.1:
> Unless otherwise specified (either explicitly or by defining a
> function in terms of other functions), invoking a container
> member function or passing a container as an argument to a
> library function shall not invalidate iterators to, or change
> the values of, objects within that container.
Doesn't this imply that sort() cannot change the order of the
elements? (Which would, of course, make it useless.)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: "Bo Persson" <bop2@telia.com>
Date: 31 Jul 2002 11:35:21 GMT Raw View
"Allan W" <Allan_W@my-dejanews.com> skrev i meddelandet
news:23b84d65.0207301534.416249bc@posting.google.com...
> Defect Report 51 (at
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#51 )
> discusses the operation of list<>::sort(). The proposed resolution
> says to add this text at the end of paragraph 23.1:
>
> > Unless otherwise specified (either explicitly or by defining a
> > function in terms of other functions), invoking a container
> > member function or passing a container as an argument to a
> > library function shall not invalidate iterators to, or change
> > the values of, objects within that container.
>
> Doesn't this imply that sort() cannot change the order of the
> elements? (Which would, of course, make it useless.)
>
Yes, it would, but...
The paragraph says nothing about the order of the values, just the values
themselves. After a sort() the values are still present, just in a slightly
different order.
Bo Persson
bop2@telia.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kanze@gabi-soft.de (James Kanze)
Date: Thu, 1 Aug 2002 17:57:37 GMT Raw View
Allan_W@my-dejanews.com (Allan W) wrote in message
news:<23b84d65.0207301534.416249bc@posting.google.com>...
> Defect Report 51 (at
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#51 )
> discusses the operation of list<>::sort(). The proposed resolution
> says to add this text at the end of paragraph 23.1:
> > Unless otherwise specified (either explicitly or by defining a
> > function in terms of other functions), invoking a container member
> > function or passing a container as an argument to a library function
> > shall not invalidate iterators to, or change the values of, objects
> > within that container.
> Doesn't this imply that sort() cannot change the order of the
> elements? (Which would, of course, make it useless.)
It would, except for the "Unless otherwise specified..." at the start.
I presume that the specification of sort requires it to change the order
of the values in the container (unless the container is already sorted).
--
James Kanze mailto:jkanze@caicheuvreux.com
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]