deduction guides for std::queue

Defined in header <queue>
template<class Container>
queue(Container)
  -> queue<typename Container::value_type, Container>;
(1) (since C++17)
template<class Container, class Allocator> 
queue(Container, Allocator)
  -> queue<typename Container::value_type, Container>;
(2) (since C++17)

These deduction guides are provided for queue to allow deduction from underlying container type. This overload only participates in overload resolution if Alloc satisfies Allocator, and Container does not satisfy Allocator and, for overload (2), if std::uses_allocator_v<Container, Allocator> 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::queue s{v};    // guide #1 deduces std::queue<int, vector<int>>
}

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/container/queue/deduction_guides