This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/67085] priority queue should not copy comparators when calling push_heap and pop_heap


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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]