deduction guides for std::priority_queue
Defined in header <queue>
|
||
template <class Compare, class Container> priority_queue(Compare, Container) |
(1) | (since C++17) |
template<class InputIt, class Comp = std::less<typename std::iterator_traits<InputIt>::value_type>, |
(2) | (since C++17) |
template<class Comp, class Container, class Alloc> priority_queue(Comp, Container, Alloc) |
(2) | (since C++17) |
These deduction guides are provided for std::priority_queue to allow deduction from underlying container type (overloads (1,3)) and from an iterator range (overload (2)) This overload only participates in overload resolution if InputIt
satisfies LegacyInputIterator, Alloc
satisfies Allocator, Comp
does not satisfy Allocator, Container
does not satisfy Allocator and, for overload (3), if std::uses_allocator_v<Container, Alloc> is true
Note: the extent to which the library determines that a type does not satisfy LegacyInputIterator is unspecified, except that as a minimum integral types do not qualify as input iterators. Likewise, the extent to which it determines that a type does not satisfy Allocator is unspecified, except that as a minimum the member type Alloc::value_type
must exist and the expression std::declval<Alloc&>().allocate(std::size_t{}) must be well-formed when treated as an unevaluated operand.
Example
#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> }