deduction guides for
std::priority_queue
|
Definiert in Header
<queue>
|
||
|
template
<
class
Comp,
class
Container
>
priority_queue
(
Comp, Container
)
|
(1) | (seit C++17) |
|
template
<
class
InputIt,
class
Comp
=
std::
less
<
/*iter-val-t*/
<
InputIt
>>
,
|
(2) | (seit C++17) |
|
template
<
class
Comp,
class
Container,
class
Alloc
>
priority_queue
(
Comp, Container, Alloc
)
|
(3) | (seit C++17) |
|
template
<
class
InputIt,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Alloc
)
|
(4) | (seit C++17) |
|
template
<
class
InputIt,
class
Comp,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Comp, Alloc
)
|
(5) | (seit C++17) |
|
template
<
class
InputIt,
class
Comp,
class
Container,
class
Alloc
>
priority_queue
(
InputIt, InputIt, Comp, Container, Alloc
)
|
(6) | (seit C++17) |
|
template
<
ranges::
input_range
R,
class
Comp
=
std::
less
<
ranges::
range_value_t
<
R
>>
>
|
(7) | (seit C++23) |
|
template
<
ranges::
input_range
R,
class
Comp,
class
Alloc
>
priority_queue
(
std::
from_range_t
, R
&&
, Comp, Alloc
)
|
(8) | (seit C++23) |
|
template
<
ranges::
input_range
R,
class
Alloc
>
priority_queue
(
std::
from_range_t
, R
&&
, Alloc
)
|
(9) | (seit C++23) |
|
Nur zur Darstellung dienende Hilfstyp-Aliase
|
||
|
template
<
class
InputIt
>
using
/*iter-val-t*/
=
|
( nur zur Darstellung* ) | |
Die folgenden Deduktionsführer werden für std::priority_queue bereitgestellt:
Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn
-
InputIterfüllt LegacyInputIterator , -
Comperfüllt nicht Allocator , -
Containererfüllt nicht Allocator , -
für Überladungen
(
4,5
)
,
(seit C++23)
Allocerfüllt Allocator , und - für Überladungen ( 3,6 ) , std:: uses_allocator_v < Container, Alloc > ist true .
Hinweis: Das Ausmaß, in dem die Bibliothek feststellt, dass ein Typ nicht
LegacyInputIterator
erfüllt, ist nicht spezifiziert, außer dass mindestens integrale Typen nicht als Input-Iteratoren qualifizieren. Ebenso ist das Ausmaß, in dem sie feststellt, dass ein Typ nicht
Allocator
erfüllt, nicht spezifiziert, außer dass mindestens der Member-Typ
Alloc::value_type
existieren muss und der Ausdruck
std::
declval
<
Alloc
&
>
(
)
.
allocate
(
std::
size_t
{
}
)
wohlgeformt sein muss, wenn er als nicht ausgewerteter Operand behandelt wird.
Hinweise
| Feature-Test Makro | Wert | Std | Funktion |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | Ranges-bewusste Konstruktion und Einfügung; Überladungen ( 7-9 ) |
Beispiel
#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'; }
Ausgabe:
1 2 3 4 4 3 2 1
Fehlerberichte
Die folgenden verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.
| DR | Angewendet auf | Verhalten wie veröffentlicht | Korrektes Verhalten |
|---|---|---|---|
| LWG 3506 | C++17 | Deduction Guides für Iterator und Allocator fehlten | hinzugefügt, ( 4-6 ) |