[patch] avoid the use of default constructors in stl_algo.h
Gunter Winkler
guwi17@gmx.de
Wed Feb 14 18:01:00 GMT 2007
Hello,
while trying to optimize a custom (random access) iterator I found that
some implementations of STL algorithms rely on the presence of a
default constructor [1]. This is IMO unnecessary, because all iterators
used in algorithms like lower_bound are (modified) copies of the
initial iterators. Thus only a copy constructor is needed. The attached
patch replaces declarations like
_ForwardIterator __left;
...
__left = __first;
by
_ForwardIterator __left = __first;
[1] The STL documentation from SGI requires each iterator to have a
valid default constructor. However, I found no rationale why.
Additionally, I don't know any algorithm that uses an iterator which is
not related to the arguments of the function.
The patch has no influence on the results of make check-c++ (SVN head).
What do you think?
mfg
Gunter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stl_algo_avoid_default_constructor1.diff
Type: text/x-diff
Size: 4282 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20070214/20ac02a6/attachment.bin>
More information about the Libstdc++
mailing list