---
name: "__gnu_pbds::priority_queue"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_pbds::priority_queue"
---

# \_\_gnu\_pbds::priority\_queue(3)

## NAME

\_\_gnu\_pbds::priority\_queue\< \_Tv, Cmp\_Fn, Tag, \_Alloc \>

## SYNOPSIS

\#include \<priority\_queue.hpp\>

### Public Types

typedef \_Alloc **allocator\_type**\
 typedef Cmp\_Fn **cmp\_fn**\
 typedef base\_type::const\_iterator **const\_iterator**\
 typedef \_\_rebind\_va::const\_pointer **const\_pointer**\
 typedef \_\_rebind\_va::const\_reference **const\_reference**\
 typedef Tag **container\_category**\
 typedef allocator\_type::difference\_type **difference\_type**\
 typedef base\_type::iterator **iterator**\
 typedef base\_type::point\_const\_iterator **point\_const\_iterator**\
 typedef base\_type::point\_iterator **point\_iterator**\
 typedef \_\_rebind\_va::pointer **pointer**\
 typedef \_\_rebind\_va::reference **reference**\
 typedef allocator\_type::size\_type **size\_type**\
 typedef \_Tv **value\_type**\

### Public Member Functions

**priority\_queue** (const cmp\_fn &r\_cmp\_fn)\
 Constructor taking some policy objects. r\_cmp\_fn will be copied by the Cmp\_Fn object of the container object.  **priority\_queue** (const priority\_queue &other)\
 template\<typename It\> **priority\_queue** (It first\_it, It last\_it)\
 Constructor taking \_\_iterators to a range of value\_types. The value\_types between first\_it and last\_it will be inserted into the container object.  template\<typename It\> **priority\_queue** (It first\_it, It last\_it, const cmp\_fn &r\_cmp\_fn)\
 Constructor taking \_\_iterators to a range of value\_types and some policy objects The value\_types between first\_it and last\_it will be inserted into the container object. r\_cmp\_fn will be copied by the cmp\_fn object of the container object.  priority\_queue & **operator=** (const priority\_queue &other)\
 void **swap** (priority\_queue &other)\

## Detailed Description

### template\<typename \_Tv, typename Cmp\_Fn = std::less\<\_Tv\>, typename Tag = pairing\_heap\_tag, typename \_Alloc = std::allocator\<char\>\>

class \_\_gnu\_pbds::priority\_queue\< \_Tv, Cmp\_Fn, Tag, \_Alloc \>"A priority queue composed of one specific heap policy.

**Template Parameters**

*\_Tv* Value type. \
 *Cmp\_Fn* Comparison functor. \
 *Tag* Instantiating data structure type, see container\_tag. \
 *\_Alloc* Allocator type.

Base is dispatched at compile time via Tag, from the following choices: binary\_heap\_tag, binomial\_heap\_tag, pairing\_heap\_tag, rc\_binomial\_heap\_tag, thin\_heap\_tag

Base choices are: detail::binary\_heap, detail::binomial\_heap, detail::pairing\_heap, detail::rc\_binomial\_heap, detail::thin\_heap.

## Constructor & Destructor Documentation

### template\<typename \_Tv, typename Cmp\_Fn = std::less\<\_Tv\>, typename Tag = pairing\_heap\_tag, typename \_Alloc = std::allocator\<char\>\> \_\_gnu\_pbds::priority\_queue\< \_Tv, Cmp\_Fn, Tag, \_Alloc \>::priority\_queue (const cmp\_fn & r\_cmp\_fn) \[inline\]

Constructor taking some policy objects. r\_cmp\_fn will be copied by the Cmp\_Fn object of the container object.

### template\<typename \_Tv, typename Cmp\_Fn = std::less\<\_Tv\>, typename Tag = pairing\_heap\_tag, typename \_Alloc = std::allocator\<char\>\> template\<typename It\> \_\_gnu\_pbds::priority\_queue\< \_Tv, Cmp\_Fn, Tag, \_Alloc \>::priority\_queue (It first\_it, It last\_it) \[inline\]

Constructor taking \_\_iterators to a range of value\_types. The value\_types between first\_it and last\_it will be inserted into the container object.

### template\<typename \_Tv, typename Cmp\_Fn = std::less\<\_Tv\>, typename Tag = pairing\_heap\_tag, typename \_Alloc = std::allocator\<char\>\> template\<typename It\> \_\_gnu\_pbds::priority\_queue\< \_Tv, Cmp\_Fn, Tag, \_Alloc \>::priority\_queue (It first\_it, It last\_it, const cmp\_fn & r\_cmp\_fn) \[inline\]

Constructor taking \_\_iterators to a range of value\_types and some policy objects The value\_types between first\_it and last\_it will be inserted into the container object. r\_cmp\_fn will be copied by the cmp\_fn object of the container object.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
