deductionguidesforstd::queue (3) - Linux Manuals

deductionguidesforstd::queue: deductionguidesforstd::queue

NAME

deductionguidesforstd::queue - deductionguidesforstd::queue

Synopsis


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


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


// Run this code


  #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>>
  }