PR67085 pass comparison functions by reference in heap algorithms
authorJonathan Wakely <jwakely@redhat.com>
Thu, 19 Jan 2017 23:07:52 +0000 (23:07 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 Jan 2017 23:07:52 +0000 (23:07 +0000)
commit437f43cc78d4607e72d7873b64342de2ce2d75cc
treee2fdd14f91b9a394be11153c1426b2348fc1f013
parentd445d739b91c2e68c2b13c265910ecf24511f3a3
PR67085 pass comparison functions by reference in heap algorithms

PR libstdc++/67085
* include/bits/predefined_ops.h (_Iter_less_val, _Val_less_iter): Add
converting constructors from _Iter_less_iter.
(_Iter_comp_val, _Val_comp_iter): Add converting constructors from
_Iter_comp_iter.
(__iter_comp_val(_Iter_comp_iter<C>): Use converting constructor.
(__val_comp_iter(_Iter_comp_iter<C>): Likewise.
* include/bits/stl_heap.h (__is_heap_until, __push_heap, __pop_heap)
(__make_heap, __sort_heap): Change _Compare parameters to references.
(__is_heap, push_heap, __adjust_heap, __pop_heap, pop_heap)
(__make_heap, make_heap, sort_heap, is_heap_until): Pass comparison
functions as lvalues.
(is_heap): Call __is_heap_until directly to avoid copying __comp.
* testsuite/23_containers/priority_queue/67085.cc: Adjust test to
count copies during construction with empty sequence.

From-SVN: r244656
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/predefined_ops.h
libstdc++-v3/include/bits/stl_heap.h
libstdc++-v3/testsuite/23_containers/priority_queue/67085.cc