This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2537. Constructors for priority_queue taking allocators should call make_heap

Section: 23.6.4.3 [priqueue.cons.alloc] Status: C++17 Submitter: Eric Schmidt Opened: 2015-09-19 Last modified: 2017-07-30

Priority: 0

View all issues with C++17 status.

Discussion:

priority_queue constructors taking both Container and Alloc arguments should finish by calling make_heap, just as with the constructors that do not have allocator parameters.

The current reading of 23.6.4.3 [priqueue.cons.alloc], if followed strictly, would effectively require calling code to ensure that the container argument is already a heap, which is probably not what was intended.

[2015-10, Kona issue prioritization]

Priority 0, move to Ready

Proposed resolution:

This wording is relative to N4527.

  1. Change 23.6.4.3 [priqueue.cons.alloc] as indicated:

    template <class Alloc>
    priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
    

    -4- Effects: Initializes c with cont as the first argument and a as the second argument, and initializes comp with compare; calls make_heap(c.begin(), c.end(), comp).

    template <class Alloc>
    priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
    

    -5- Effects: Initializes c with std::move(cont) as the first argument and a as the second argument, and initializes comp with compare; calls make_heap(c.begin(), c.end(), comp).