Topic: swappable sequences" and extending the applicability of std
Author: caj@cs.york.ac.uk (Christopher Jefferson)
Date: Wed, 13 Apr 2005 05:51:58 GMT Raw View
Joaqu=EDn M L=F3pez Mu=F1oz wrote:
> Currently, std algorithms are classified into
> nonmodifying, modifying and sorting. It turns out that
> the two latter categories can be further refined so
> that, with some stricter specifications in the std,
> some of their algorithms are applicable to a wider
> spectrum of situations:
>=20
> <snip>
>
> Note that my proposal is actually an extension
> of N1523:
>=20
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1523.htm
>
You should read n1771 which is actually explaining the effect of n1770=20
(move symantics) on the standard library. It discusses exactly what you=20
say (that some algorithms can be implemented purely in terms of swap).
One thing to note (which I came across) is that while in theory all of=20
the standard algorithms can be implemented purely in terms of swap and=20
nothing else, it is generally not adviseable to do so, as it often=20
produces a decrease in speed for types like char, int, etc. Things like=20
"reverse" and "swap_ranges" are almost always implemented using=20
iter_swap, but while you could write an only-swapping "sort" or=20
"rotate", it would be slower on ints, chars, and other small types.
> And that's it. Comments/suggestions? Does this make
> any sense?
>=20
I'd say it makes a lots of sense, and both this, and move symantics=20
(which are kind of related to what you are saying, try reading 1770 and=20
1771, although I found 1770 a bit dense) are important both for faster=20
and safer implementation in my opinion.
Chris
---
[ 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 ]