This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/67085] priority queue should not copy comparators when calling push_heap and pop_heap
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 01 Aug 2015 00:44:59 +0000
- Subject: [Bug libstdc++/67085] priority queue should not copy comparators when calling push_heap and pop_heap
- Auto-submitted: auto-generated
- References: <bug-67085-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67085
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |WONTFIX
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Calcutt from comment #1)
> typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
> std::push_heap<_Sequence::iterator,_Comp_ref>(c.begin(), c.end(), comp);
Apart from the fact that this is not valid in C++03, this is not how push_heap
is meant to be used. It is defined to take its arguments by value, not by
reference, so it's expected to be cheap to copy the functor, which is common to
all STL algorithms. I see no reason to change that just for priority_queue
(although if we were to do it I'd use std::ref not std::add_lvalue_reference).