- algorithm[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
template <class RandomAccessIterator>
bool is_heap(RandomAccessIterator first,
RandomAccessIterator last); // (1) C++11
template <class RandomAccessIterator>
constexpr bool is_heap(RandomAccessIterator first,
RandomAccessIterator last); // (1) C++20
template <class RandomAccessIterator, class Compare>
bool is_heap(RandomAccessIterator first,
RandomAccessIterator last,
Compare comp); // (2) C++11
template <class RandomAccessIterator, class Compare>
constexpr bool is_heap(RandomAccessIterator first,
RandomAccessIterator last,
Compare comp); // (2) C++20
template <class ExecutionPolicy, class RandomAccessIterator>
bool is_heap(ExecutionPolicy&& exec,
RandomAccessIterator first,
RandomAccessIterator last); // (3) C++17
template <class ExecutionPolicy, class RandomAccessIterator, class Compare>
bool is_heap(ExecutionPolicy&& exec,
RandomAccessIterator first,
RandomAccessIterator last,
Compare comp); // (4) C++17
}
範囲がヒープ化されているか判定する。
- (1) :
is_heap_until
(first, last) == last
- (2) :
is_heap_until
(first, last, comp) == last
- (3) :
is_heap_until
(
std::forward
<ExecutionPolicy>(exec), first, last) == last
- (4) :
is_heap_until
(
std::forward
<ExecutionPolicy>(exec), first, last, comp) == last
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<int> v = {3, 1, 4};
std::cout << std::boolalpha;
std::cout << "before: is heap? "
<< std::is_heap(v.begin(), v.end()) << std::endl;
std::make_heap(v.begin(), v.end());
std::cout << " after: is heap? "
<< std::is_heap(v.begin(), v.end()) << std::endl;
}
- std::is_heap[color ff0000]
- std::make_heap[link make_heap.md]
before: is heap? false
after: is heap? true
- C++11
- Clang: ??
- GCC: 4.7.0
- ICC: ??
- Visual C++: 2010, 2012, 2013, 2015
- 2008では、
_HAS_TRADITIONAL_STL
を1に定義してから<algorithm>
をインクルードすると、stdext
名前空間でis_heap
が定義される。
- 2008では、