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: "konig121 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Aug 2015 19:53:43 +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
--- Comment #3 from Andrew Calcutt <konig121 at gmail dot com> ---
Hi Jonathan,
I can understand your reservation, but it seems to me like there is a case for
making this change if the comparator provided to the priority_queue was
explicitly a reference type. For example:
std::priority_queue<int, std::vector<int>, MyComparator&> queue;
would create an object which contained a reference to an external comparator.
Even in this case, however, the heap operations would use a copy of the
provided comparator. I believe that fixing this would allow for move only
comparators to be used, and would not require as complex a change. Simply
providing the comparator type to the heap calls would be sufficient without
requiring std::ref.
Are there technical reasons this is not desirable or possible beyond what you
have already stated? Is the behavior of the priority queue here also outside of
the intent of the standard?
Thanks,
Andrew