deduction guides for
std::priority_queue
|
ヘッダーで定義
<queue>
|
||
|
template
<
class
Comp,
class
Container
>
priority_queue
(
Comp, Container
)
|
(1) | (C++17以降) |
|
template
<
class
InputIt,
class
Comp
=
std::
less
<
/*iter-val-t*/
<
InputIt
>>
,
|
(2) | (C++17以降) |
|
template
<
class
Comp,
class
Container,
class
Alloc
>
priority_queue
(
Comp, Container, Alloc
)
|
(3) | (C++17以降) |
|
template
<
class
InputIt,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Alloc
)
|
(4) | (C++17以降) |
|
template
<
class
InputIt,
class
Comp,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Comp, Alloc
)
|
(5) | (C++17以降) |
|
template
<
class
InputIt,
class
Comp,
class
Container,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Comp, Container, Alloc
)
|
(6) | (C++17以降) |
|
template
<
ranges::
input_range
R,
class
Comp
=
std::
less
<
ranges::
range_value_t
<
R
>>
>
|
(7) | (C++23以降) |
|
template
<
ranges::
input_range
R,
class
Comp,
class
Alloc
>
priority_queue
(
std::
from_range_t
, R
&&
, Comp, Alloc
)
|
(8) | (C++23以降) |
|
template
<
ranges::
input_range
R,
class
Alloc
>
priority_queue
(
std::
from_range_t
, R
&&
, Alloc
)
|
(9) | (C++23以降) |
|
説明専用ヘルパー型エイリアス
|
||
|
template
<
class
InputIt
>
using
/*iter-val-t*/
=
|
( 説明専用* ) | |
以下の デダクションガイド が std::priority_queue に対して提供されています:
これらのオーバーロードは、以下の条件でのみオーバーロード解決に参加します:
-
InputItは LegacyInputIterator を満たす、 -
Compは Allocator を満たさない、 -
Containerは Allocator を満たさない、 -
オーバーロード
(
4,5
)
に対して、
(C++23以降)
Allocは Allocator を満たし、かつ - オーバーロード ( 3,6 ) に対して、 std:: uses_allocator_v < Container, Alloc > が true である。
注意: ライブラリが型が
LegacyInputIterator
を満たさないと判断する程度は未規定であるが、少なくとも整数型は入力イテレータとして適格ではない。同様に、型が
Allocator
を満たさないと判断する程度も未規定であるが、少なくともメンバ型
Alloc::value_type
が存在しなければならず、式
std::
declval
<
Alloc
&
>
(
)
.
allocate
(
std::
size_t
{
}
)
が未評価オペランドとして扱われる場合に整形式でなければならない。
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | Ranges-aware 構築と挿入; オーバーロード ( 7-9 ) |
例
#include <functional> #include <iostream> #include <queue> #include <vector> int main() { const std::vector<int> v = {1, 2, 3, 4}; std::priority_queue pq1{std::greater<int>{}, v}; // deduces std::priority_queue< // int, std::vector<int>, // std::greater<int>> for (; !pq1.empty(); pq1.pop()) std::cout << pq1.top() << ' '; std::cout << '\n'; std::priority_queue pq2{v.begin(), v.end()}; // deduces std::priority_queue<int> for (; !pq2.empty(); pq2.pop()) std::cout << pq2.top() << ' '; std::cout << '\n'; }
出力:
1 2 3 4 4 3 2 1
欠陥報告
以下の動作変更に関する欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3506 | C++17 | イテレータとアロケータからの推論ガイドが欠落していた | 追加、 ( 4-6 ) |