Remove algorithms implementation duplications
François Dumont
frs.dumont@gmail.com
Fri Jul 13 09:04:00 GMT 2012
Hi
Here is the new patch based on Marc Glisse idea to use functors
taking iterators rather than iterators::reference. Compare to the
previous proposal there is no more impact on the creation of temporaries
instances, no additional copy or move constructor. Of course there are
additional iterators or functors copies but those types are supposed to
be lightweight types easy to copy.
I have taken this opportunity to also clean the instantiation of
types used in concept checks. There have been patches recently to avoid
instantiation of the iterator_traits type that became unused if concepts
checks are disabled, I have clean this issue in the impacted files.
Note also that this patch in addition to cleaning libstdc++ code
will also benefit to our users:
- concept check are no repeated each time an algo call an other
algo. Now concept checks are done in Standard algo implementations and
those implementations only use internal functions, the "__XXX"
functions, that do not redo the checks
- the search algo taking a predicate was not using the find_if
algo. When I kept only one implementation of search I use the one with
the __find_if call to benefit from its specialization for random access
iterators.
I also wonder if I shouldn't move all the implementation details in
the std::__detail namespace ? Should I do it now, before eventually
applying the patch ?
Tested under linux x86_64 normal, debug and C++11-normal modes.
2012-07-11 François Dumont <fdumont@gcc.gnu.org>
* include/bits/predefined_ops.h: New. Internal functors use to
avoid algorithm duplications.
* include/bits/stl_algobase.h, stl_algo.h, stl_heap.h: Adapt to
use latter functors, remove many algorithm duplications.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: algos.patch
Type: text/x-patch
Size: 189820 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120713/f47f4cbd/attachment.bin>
More information about the Libstdc++
mailing list