Title
priority_queue::push_range needs to append_range
Status
c++23
Section
[priqueue.members]
Submitter
Casey Carter

Created on 2022-06-20.00:00:00 last changed 13 months ago

Messages

Date: 2023-02-13.11:31:32

Proposed resolution:

This wording is relative to N4910.

  1. Modify [priqueue.members] as indicated:

    template<container-compatible-range<T> R>
      void push_range(R&& rg);
    

    -3- Effects: Inserts all elements of rg in c via c.append_range(std::forward<R>(rg)) if that is a valid expression, or ranges::copy(rg, back_inserter(c)) otherwise. Then restores the heap property as if by make_heap(c.begin(), c.end(), comp).

    -4- Postconditions: is_heap(c.begin(), c.end(), comp) is true.

Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP. ]

Date: 2023-02-08.23:17:32

[ Issaquah 2023-02-08; LWG ]

Unanimous consent to move to Immediate.

Date: 2022-07-15.00:00:00

[ 2022-07-08; Reflector poll ]

Set priority to 2 after reflector poll.

Date: 2022-06-20.00:00:00

The push_range members of the queue ([queue.mod]) and stack ([stack.mod]) container adaptors are both specified as "Effects: Equivalent to c.append_range(std::forward<R>(rg)) if that is a valid expression, otherwise ranges::copy(rg, back_inserter(c)).". For priority_queue, however, we have instead ([priqueue.members]):

-3- Effects: Insert all elements of rg in c.

-4- Postconditions: is_heap(c.begin(), c.end(), comp) is true.

Since append_range isn't one of the operations required of the underlying container, "Insert all elements of rg" must be implemented via potentially less efficient means. It would be nice if this push_back could take advantage of append_range when it's available just as do the other two overloads.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 11:31:32adminsetmessages: + msg13382
2023-02-13 11:31:32adminsetstatus: immediate -> wp
2023-02-08 23:17:32adminsetmessages: + msg13294
2023-02-08 23:17:32adminsetstatus: new -> immediate
2022-07-08 20:04:38adminsetmessages: + msg12563
2022-06-26 08:03:02adminsetmessages: + msg12535
2022-06-20 00:00:00admincreate