Remove algo duplications

François Dumont frs.dumont@gmail.com
Tue Jun 12 20:06:00 GMT 2012


Hi

     Here is a new version of the patch to remove duplication of algo 
implementations.

     Compared to the previous version I have rename functors that apply 
to iterators (iter_less, iter_equal_to). I have also added move 
semantics when iterator dereference operator returns anything except 
lvalue reference (rvalue reference or an instance).

2012-06-12  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.
     * testsuite/util/testsuite_counter_type.h: New.
     * testsuite/25_algorithms/lower_bound/3.cc, 4.cc: New.

     I don't think tests are to be added. They are not really tests but 
rather use cases to experiment impact of the patch in different 
situtations, with/without -fno-elide-constructors, in C++ 11 or C++98. 
You can see in those the impact of the patch which is more or less what 
Marc Glisse already remarked. You can see an impact mostly when the 
iterator::reference type is not a reference, there are additional copies 
then. But I still think this patch make sens cause it greatly simplify 
library code.

     Tested under linux x86_64.

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: algos.patch
Type: text/x-patch
Size: 126258 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120612/a04a6984/attachment.bin>


More information about the Libstdc++ mailing list