---
name: "__gnu_pbds::tree"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_pbds::tree/3cxx"
---

# \_\_gnu\_pbds::tree(3cxx)

## NAME

\_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>

## SYNOPSIS

`#include <assoc_container.hpp>`

Inherits **\_\_gnu\_pbds::basic\_branch\< Key, Mapped, Tag, Node\_Update, Policy\_Tl, \_Alloc \>**.

### Public Types

typedef Cmp\_Fn **cmp\_fn**\
 Comparison functor type.  typedef Node\_Update **node\_update**\

### Public Member Functions

**tree** (const **cmp\_fn** &c)\
 Constructor taking some policy objects. r\_cmp\_fn will be copied by the Cmp\_Fn object of the container object.  **tree** (const **tree** &other)\
 template\<typename It \> **tree** (It first, It last)\
 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 \> **tree** (It first, It last, const **cmp\_fn** &c)\
 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.  **tree** & **operator=** (const **tree** &other)\
 void **swap** (**tree** &other)\

## Detailed Description

### template\<typename Key, typename Mapped, typename Cmp\_Fn = std::less\<Key\>, typename Tag = rb\_tree\_tag, template\< typename Node\_CItr, typename Node\_Itr, typename Cmp\_Fn\_, typename \_Alloc\_ \> class Node\_Update = null\_node\_update, typename \_Alloc = std::allocator\<char\>\>

class \_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>"A tree-based container.

**Template Parameters**

*Key* Key type. \
 *Mapped* Map type. \
 *Cmp\_Fn* Comparison functor. \
 *Tag* Instantiating data structure type, see container\_tag. \
 *Node\_Update* Updates tree internal-nodes, restores invariants when invalidated. XXX See design::tree-based-containersnode invariants. \
 *\_Alloc* Allocator type.

Base tag choices are: ov\_tree\_tag, rb\_tree\_tag, splay\_tree\_tag.

Base is basic\_branch.

## Member Typedef Documentation

### template\<typename Key , typename Mapped , typename Cmp\_Fn = std::less\<Key\>, typename Tag = rb\_tree\_tag, template\< typename Node\_CItr, typename Node\_Itr, typename Cmp\_Fn\_, typename \_Alloc\_ \> class Node\_Update = null\_node\_update, typename \_Alloc = std::allocator\<char\>\> typedef Cmp\_Fn \_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>::cmp\_fn

Comparison functor type.

## Constructor & Destructor Documentation

### template\<typename Key , typename Mapped , typename Cmp\_Fn = std::less\<Key\>, typename Tag = rb\_tree\_tag, template\< typename Node\_CItr, typename Node\_Itr, typename Cmp\_Fn\_, typename \_Alloc\_ \> class Node\_Update = null\_node\_update, typename \_Alloc = std::allocator\<char\>\> \_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>::tree (const cmp\_fn & c)` [inline]`

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

### template\<typename Key , typename Mapped , typename Cmp\_Fn = std::less\<Key\>, typename Tag = rb\_tree\_tag, template\< typename Node\_CItr, typename Node\_Itr, typename Cmp\_Fn\_, typename \_Alloc\_ \> class Node\_Update = null\_node\_update, typename \_Alloc = std::allocator\<char\>\> template\<typename It \> \_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>::tree (It first, It last)` [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 Key , typename Mapped , typename Cmp\_Fn = std::less\<Key\>, typename Tag = rb\_tree\_tag, template\< typename Node\_CItr, typename Node\_Itr, typename Cmp\_Fn\_, typename \_Alloc\_ \> class Node\_Update = null\_node\_update, typename \_Alloc = std::allocator\<char\>\> template\<typename It \> \_\_gnu\_pbds::tree\< Key, Mapped, Cmp\_Fn, Tag, Node\_Update, \_Alloc \>::tree (It first, It last, const cmp\_fn & c)` [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.
