Deduktionshilfen für 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-value-type*/<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) |
Die folgenden Deduktionshilfen sind für std::priority_queue verfügbar
It.Diese Überladungen nehmen nur an der Auflösung von Überladungen 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) ist std::uses_allocator_v<Container, Alloc> true.
Hinweis: Das Ausmaß, in dem die Bibliothek feststellt, dass ein Typ LegacyInputIterator nicht erfüllt, ist nicht spezifiziert, außer dass ganzzahlige Typen als Eingabeiteratoren nicht qualifiziert sind. Ebenso ist das Ausmaß, in dem sie feststellt, dass ein Typ Allocator nicht erfüllt, nicht spezifiziert, außer dass als Minimum der Mitgliedstyp Alloc::value_type existieren muss und der Ausdruck std::declval<Alloc&>().allocate(std::size_t{}) als nicht ausgewerteter Operand gut geformt sein muss.
[bearbeiten] Hinweise
| Feature-Test-Makro | Wert | Std | Feature |
|---|---|---|---|
__cpp_lib_containers_ranges |
202202L |
(C++23) | Bereichsweise Konstruktion und Einfügung; Überladungen (7-9) |
[bearbeiten] 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
[bearbeiten] Fehlerberichte
Die folgenden Verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.
| DR | angewendet auf | Verhalten wie veröffentlicht | Korrigiertes Verhalten |
|---|---|---|---|
| LWG 3506 | C++17 | Deduktionshilfen von Iterator und Allokator fehlten | hinzugefügt |