[queue.defn] # 23 Containers library [[containers]](./#containers) ## 23.6 Container adaptors [[container.adaptors]](container.adaptors#queue.defn) ### 23.6.3 Class template queue [[queue]](queue#defn) #### 23.6.3.1 Definition [queue.defn] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15635) Any sequence container supporting operationsfront(),back(),push_back() andpop_front() can be used to instantiatequeue[.](#1.sentence-1) In particular, and can be used[.](#1.sentence-2) namespace std {template>class queue {public:using value_type = typename Container::value_type; using reference = typename Container::reference; using const_reference = typename Container::const_reference; using size_type = typename Container::size_type; using container_type = Container; protected: Container c; public:constexpr queue() : queue(Container()) {}constexpr explicit queue(const Container&); constexpr explicit queue(Container&&); template constexpr queue(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") R> constexpr queue(from_range_t, R&& rg); template constexpr explicit queue(const Alloc&); template constexpr queue(const Container&, const Alloc&); template constexpr queue(Container&&, const Alloc&); template constexpr queue(const queue&, const Alloc&); template constexpr queue(queue&&, const Alloc&); templateconstexpr queue(InputIterator first, InputIterator last, const Alloc&); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") R, class Alloc>constexpr queue(from_range_t, R&& rg, const Alloc&); constexpr bool empty() const { return c.empty(); }constexpr size_type size() const { return c.size(); }constexpr reference front() { return c.front(); }constexpr const_reference front() const { return c.front(); }constexpr reference back() { return c.back(); }constexpr const_reference back() const { return c.back(); }constexpr void push(const value_type& x) { c.push_back(x); }constexpr void push(value_type&& x) { c.push_back(std::move(x)); }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") R> constexpr void push_range(R&& rg); templateconstexpr decltype(auto) emplace(Args&&... args){ return c.emplace_back(std::forward(args)...); }constexpr void pop() { c.pop_front(); }constexpr void swap(queue& q) noexcept(is_nothrow_swappable_v){ using std::swap; swap(c, q.c); }}; template queue(Container) -> queue; template queue(InputIterator, InputIterator) -> queue<*iter-value-type*>; template queue(from_range_t, R&&) -> queue>; template queue(Container, Allocator) -> queue; template queue(InputIterator, InputIterator, Allocator)-> queue<*iter-value-type*, deque<*iter-value-type*, Allocator>>; template queue(from_range_t, R&&, Allocator)-> queue, deque, Allocator>>; templatestruct uses_allocator, Alloc>: uses_allocator::type { };}