namespace std::ranges {
// (1)
template<random_access_iterator I, sentinel_for<I> S, class Proj = identity, indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {});
// (2)
template<random_access_range R, class Proj = identity, indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {});
}
概要
範囲がヒープ化されているか判定する。
- (1): イテレータペアで範囲を指定する
- (2): 範囲を直接指定する
効果
ranges::is_heap_until(first, last, comp, proj) == 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::ranges::is_heap(v) << std::endl;
std::ranges::make_heap(v);
std::cout << " after: is heap? "
<< std::ranges::is_heap(v) << std::endl;
}
出力
before: is heap? false
after: is heap? true
バージョン
言語
- C++20
処理系
- Clang: ??
- GCC: 10.1.0
- ICC: ??
- Visual C++: 2019 Update 10