# 11 Algorithms library [algorithms]

## 11.5 Sorting and related operations [alg.sorting]

### 11.5.6 Heap operations [alg.heap.operations]

#### 11.5.6.5is_heap[is.heap]

``` template <RandomAccessIterator I, Sentinel<I> S, class Proj = identity, IndirectStrictWeakOrder<projected<I, Proj>> Comp = less<>> bool is_heap(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}); template <RandomAccessRange Rng, class Proj = identity, IndirectStrictWeakOrder<projected<iterator_t<Rng>, Proj>> Comp = less<>> bool is_heap(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}); ```

Returns: is_heap_until(first, last, comp, proj) == last

``` template <RandomAccessIterator I, Sentinel<I> S, class Proj = identity, IndirectStrictWeakOrder<projected<I, Proj>> Comp = less<>> I is_heap_until(I first, S last, Comp comp = Comp{}, Proj proj = Proj{}); template <RandomAccessRange Rng, class Proj = identity, IndirectStrictWeakOrder<projected<iterator_t<Rng>, Proj>> Comp = less<>> safe_iterator_t<Rng> is_heap_until(Rng&& rng, Comp comp = Comp{}, Proj proj = Proj{}); ```

Returns: If distance(first, last) < 2, returns last. Otherwise, returns the last iterator i in [first,last] for which the range [first,i) is a heap.

Complexity: Linear.