std::priority_queue
に対する推定ガイド
ヘッダ <queue> で定義
|
||
template <class Compare, class Container> priority_queue(Compare, Container) |
(1) | (C++17以上) |
template<class InputIt, class Comp = std::less<typename std::iterator_traits<InputIt>::value_type>, |
(2) | (C++17以上) |
template<class Comp, class Container, class Alloc> priority_queue(Comp, Container, Alloc) |
(2) | (C++17以上) |
基になるコンテナ型 (オーバーロード (1,3)) およびイテレータ範囲 (オーバーロード (2)) からの推定を可能とするため、これらの推定ガイドが std::priority_queue に対して提供されます。 このオーバーロードは、InputIt
が LegacyInputIterator を満たし、 Alloc
が Allocator を満たし、 Comp
が Allocator を満たさず、 Container
が Allocator を満たさず、さらに (3) に対しては std::uses_allocator_v<Container, Alloc> が true
である場合にのみ、オーバーロード解決に参加します。
ノート: ある型が LegacyInputIterator を満たさないとライブラリが判断する範囲は、少なくとも整数型が入力イテレータとして適合しないことを除いて、未規定です。 同様に、ある型が Allocator を満たさないと判断される範囲も、少なくともメンバ型 Alloc::value_type
が存在しなければならず、式 std::declval<Alloc&>().allocate(std::size_t{}) が評価されない被演算子として扱われたときに well-formed でなければならないことを除いて、未規定です。
[編集] 例
#include <vector> #include <queue> int main() { std::vector<int> v = {1,2,3,4}; std::priority_queue pq1{v}; // deduces std::priority_queue<int> std::priority_queue pq2{v.begin(), v.end()}; // deduces std::priority_queue<int> }