3.4 KiB
[make.heap]
26 Algorithms library [algorithms]
26.8 Sorting and related operations [alg.sorting]
26.8.8 Heap operations [alg.heap.operations]
26.8.8.4 make_heap [make.heap]
`template constexpr void make_heap(RandomAccessIterator first, RandomAccessIterator last);
template<class RandomAccessIterator, class Compare> constexpr void make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template<random_access_iterator I, sentinel_for S, class Comp = ranges::less, class Proj = identity> requires sortable<I, Comp, Proj> constexpr I ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); template<random_access_range R, class Comp = ranges::less, class Proj = identity> requires sortable<iterator_t, Comp, Proj> constexpr borrowed_iterator_t ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); `
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names.
Preconditions: For the overloads in namespace std,RandomAccessIterator meets the Cpp17ValueSwappable requirements ([swappable.requirements]) and the type of *first meets the Cpp17MoveConstructible (Table 31) andCpp17MoveAssignable (Table 33) requirements.
Effects: Constructs a heap with respect to comp and proj out of the range [first, last).
Returns: last for the overloads in namespace ranges.
Complexity: At most 3(last - first) comparisons and twice as many projections.