---
name: "__gnu_cxx::__alloc_traits"
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_cxx::__alloc_traits"
---

# \_\_gnu\_cxx::\_\_alloc\_traits(3)

Uniform interface to C++98 and C++11 allocators.

## NAME

\_\_gnu\_cxx::\_\_alloc\_traits\< \_Alloc, typename \> - Uniform interface to C++98 and C++11 allocators.

## SYNOPSIS

\#include \<alloc\_traits.h\>

Inherits **std::allocator\_traits\< \_Alloc \>**.

### Public Types

typedef **std::allocator\_traits**\< \_Alloc \> **\_Base\_type**\
 typedef \_Alloc **allocator\_type**\
 typedef **\_Base\_type::const\_pointer** **const\_pointer**\
 typedef const value\_type & **const\_reference**\
 using **const\_void\_pointer**\
 The allocator's const void pointer type.  typedef **\_Base\_type::difference\_type** **difference\_type**\
 using **is\_always\_equal**\
 Whether all instances of the allocator type compare equal.  typedef **\_Base\_type::pointer** **pointer**\
 using **propagate\_on\_container\_copy\_assignment**\
 How the allocator is propagated on copy assignment.  using **propagate\_on\_container\_move\_assignment**\
 How the allocator is propagated on move assignment.  using **propagate\_on\_container\_swap**\
 How the allocator is propagated on swap.  template\<typename \_Tp\> using **rebind\_alloc**\
 template\<typename \_Tp\> using **rebind\_traits**\
 typedef value\_type & **reference**\
 typedef **\_Base\_type::size\_type** **size\_type**\
 typedef **\_Base\_type::value\_type** **value\_type**\
 using **void\_pointer**\
 The allocator's void pointer type.

### Static Public Member Functions

static constexpr bool **\_S\_always\_equal** ()\
 static constexpr bool **\_S\_nothrow\_move** ()\
 static constexpr void **\_S\_on\_swap** (\_Alloc &\_\_a, \_Alloc &\_\_b)\
 static constexpr bool **\_S\_propagate\_on\_copy\_assign** ()\
 static constexpr bool **\_S\_propagate\_on\_move\_assign** ()\
 static constexpr bool **\_S\_propagate\_on\_swap** ()\
 static constexpr \_Alloc **\_S\_select\_on\_copy** (const \_Alloc &\_\_a)\
 static constexpr pointer **allocate** (\_Alloc &\_\_a, size\_type \_\_n)\
 Allocate memory.  static constexpr pointer **allocate** (\_Alloc &\_\_a, size\_type \_\_n, **const\_void\_pointer** \_\_hint)\
 Allocate memory.  static constexpr pointer **allocate** (\_Alloc &\_\_a, size\_type \_\_n)\
 Allocate memory.  static constexpr pointer **allocate** (\_Alloc &\_\_a, size\_type \_\_n, **const\_void\_pointer** \_\_hint)\
 Allocate memory.  static constexpr auto **allocate\_at\_least** (\_Alloc &\_\_a, size\_type \_\_n) -\> allocation\_result\< pointer, size\_type \>\
 Allocate memory, generously.  template\<typename \_Ptr, typename... \_Args\> static constexpr std::\_\_enable\_if\_t\< \_\_is\_custom\_pointer\< \_Ptr \>::value \> **construct** (\_Alloc &\_\_a, \_Ptr \_\_p, \_Args &&... \_\_args) noexcept(noexcept(**\_Base\_type::construct**(\_\_a, std::\_\_to\_address(\_\_p), **std::forward**\< \_Args \>(\_\_args)...)))\
 template\<typename \_Tp, typename... \_Args\> static constexpr void **construct** (\_Alloc &\_\_a, \_Tp \*\_\_p, \_Args &&... \_\_args) noexcept(\_S\_nothrow\_construct\< \_Tp, \_Args... \>())\
 Construct an object of type \_Tp.  static constexpr void **deallocate** (\_Alloc &\_\_a, pointer \_\_p, size\_type \_\_n)\
 Deallocate memory.  static constexpr void **deallocate** (\_Alloc &\_\_a, pointer \_\_p, size\_type \_\_n)\
 Deallocate memory.  template\<typename \_Ptr\> static constexpr std::\_\_enable\_if\_t\< \_\_is\_custom\_pointer\< \_Ptr \>::value \> **destroy** (\_Alloc &\_\_a, \_Ptr \_\_p) noexcept(noexcept(**\_Base\_type::destroy**(\_\_a, std::\_\_to\_address(\_\_p))))\
 template\<typename \_Tp\> static constexpr void **destroy** (\_Alloc &\_\_a, \_Tp \*\_\_p) noexcept(\_S\_nothrow\_destroy\< \_Tp \>())\
 Destroy an object of type *\_Tp*.  static constexpr size\_type **max\_size** (const \_Alloc &\_\_a) noexcept\
 The maximum supported allocation size.  static constexpr \_Alloc **select\_on\_container\_copy\_construction** (const \_Alloc &\_\_rhs)\
 Obtain an allocator to use when copying a container.

## Detailed Description

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\>

struct \_\_gnu\_cxx::\_\_alloc\_traits\< \_Alloc, typename \>"Uniform interface to C++98 and C++11 allocators.

## Member Typedef Documentation

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::const\_void\_pointer \[inherited\]

The allocator's const void pointer type. Alloc::const\_void\_pointer if that type exists, otherwise  pointer\_traits\<pointer\>::rebind\<const void\>

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::is\_always\_equal \[inherited\]

Whether all instances of the allocator type compare equal. Alloc::is\_always\_equal if that type exists, otherwise is\_empty\<Alloc\>::type

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::propagate\_on\_container\_copy\_assignment \[inherited\]

How the allocator is propagated on copy assignment. Alloc::propagate\_on\_container\_copy\_assignment if that type exists, otherwise false\_type

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::propagate\_on\_container\_move\_assignment \[inherited\]

How the allocator is propagated on move assignment. Alloc::propagate\_on\_container\_move\_assignment if that type exists, otherwise false\_type

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::propagate\_on\_container\_swap \[inherited\]

How the allocator is propagated on swap. Alloc::propagate\_on\_container\_swap if that type exists, otherwise false\_type

### template\<typename \_Alloc\> using std::allocator\_traits\< \_Alloc \>::void\_pointer \[inherited\]

The allocator's void pointer type. Alloc::void\_pointer if that type exists, otherwise  pointer\_traits\<pointer\>::rebind\<void\>

## Member Function Documentation

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> constexpr pointer std::allocator\_traits\< \_Alloc \>::allocate (\_Alloc & \_\_a, size\_type \_\_n) \[inline\], \[static\], \[nodiscard\], \[constexpr\]

Allocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_n* The number of objects to allocate space for.

Calls a.allocate(n)

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> constexpr pointer std::allocator\_traits\< \_Alloc \>::allocate (\_Alloc & \_\_a, size\_type \_\_n, const\_void\_pointer \_\_hint) \[inline\], \[static\], \[nodiscard\], \[constexpr\]

Allocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_n* The number of objects to allocate space for. \
 *\_\_hint* Aid to locality.

**Returns**

Memory of suitable size and alignment for *n* objects of type value\_type

Returns  a.allocate(n, hint)  if that expression is well-formed, otherwise returns a.allocate(n)

### template\<typename \_Alloc\> constexpr pointer std::allocator\_traits\< \_Alloc \>::allocate (\_Alloc & \_\_a, size\_type \_\_n) \[inline\], \[static\], \[nodiscard\], \[constexpr\], \[inherited\]

Allocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_n* The number of objects to allocate space for.

Calls a.allocate(n)

### template\<typename \_Alloc\> constexpr pointer std::allocator\_traits\< \_Alloc \>::allocate (\_Alloc & \_\_a, size\_type \_\_n, const\_void\_pointer \_\_hint) \[inline\], \[static\], \[nodiscard\], \[constexpr\], \[inherited\]

Allocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_n* The number of objects to allocate space for. \
 *\_\_hint* Aid to locality.

**Returns**

Memory of suitable size and alignment for *n* objects of type value\_type

Returns  a.allocate(n, hint)  if that expression is well-formed, otherwise returns a.allocate(n)

### template\<typename \_Alloc\> constexpr auto std::allocator\_traits\< \_Alloc \>::allocate\_at\_least (\_Alloc & \_\_a, size\_type \_\_n) -\> allocation\_result\< pointer, size\_type \> \[inline\], \[static\], \[nodiscard\], \[constexpr\], \[inherited\]

Allocate memory, generously.

**Parameters**

*\_\_a* An allocator. \
 *\_\_n* The minimum number of objects to allocate space for.

**Returns**

Memory of suitable size and alignment for n or more contiguous objects of type value\_type.

Returns a.allocate\_at\_least(n) if that expression is well-formed, else { a.allocate(n), n }. When an allocator is obliged to reserve more space than required for the cited n objects, it may deliver the extra space to the caller.

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> template\<typename \_Tp, typename... \_Args\> constexpr void std::allocator\_traits\< \_Alloc \>::construct (\_Alloc & \_\_a, \_Tp \* \_\_p, \_Args &&... \_\_args) \[inline\], \[static\], \[constexpr\], \[noexcept\]

Construct an object of type \_Tp.

**Parameters**

*\_\_a* An allocator. \
 *\_\_p* Pointer to memory of suitable size and alignment for Tp \
 *\_\_args* Constructor arguments.

Calls  \_\_a.construct(\_\_p, std::forward\<Args\>(\_\_args)...)  if that expression is well-formed, otherwise uses placement-new to construct an object of type *\_Tp* at location *\_\_p* from the arguments *\_\_args*...

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> constexpr void std::allocator\_traits\< \_Alloc \>::deallocate (\_Alloc & \_\_a, pointer \_\_p, size\_type \_\_n) \[inline\], \[static\], \[constexpr\]

Deallocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_p* Pointer to the memory to deallocate. \
 *\_\_n* The number of objects space was allocated for.

Calls  a.deallocate(p, n)

### template\<typename \_Alloc\> constexpr void std::allocator\_traits\< \_Alloc \>::deallocate (\_Alloc & \_\_a, pointer \_\_p, size\_type \_\_n) \[inline\], \[static\], \[constexpr\], \[inherited\]

Deallocate memory.

**Parameters**

*\_\_a* An allocator. \
 *\_\_p* Pointer to the memory to deallocate. \
 *\_\_n* The number of objects space was allocated for.

Calls  a.deallocate(p, n)

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> template\<typename \_Tp\> constexpr void std::allocator\_traits\< \_Alloc \>::destroy (\_Alloc & \_\_a, \_Tp \* \_\_p) \[inline\], \[static\], \[constexpr\], \[noexcept\]

Destroy an object of type *\_Tp*.

**Parameters**

*\_\_a* An allocator. \
 *\_\_p* Pointer to the object to destroy

Calls \_\_a.destroy(\_\_p) if that expression is well-formed, otherwise calls \_\_p-\>~\_Tp()

### template\<typename \_Alloc, typename = typename \_Alloc::value\_type\> constexpr size\_type std::allocator\_traits\< \_Alloc \>::max\_size (const \_Alloc & \_\_a) \[inline\], \[static\], \[constexpr\], \[noexcept\]

The maximum supported allocation size.

**Parameters**

*\_\_a* An allocator.

**Returns**

\_\_a.max\_size() or numeric\_limits\<size\_type\>::max()

Returns \_\_a.max\_size() if that expression is well-formed, otherwise returns numeric\_limits\<size\_type\>::max()

### template\<typename \_Alloc\> constexpr \_Alloc std::allocator\_traits\< \_Alloc \>::select\_on\_container\_copy\_construction (const \_Alloc & \_\_rhs) \[inline\], \[static\], \[constexpr\], \[inherited\]

Obtain an allocator to use when copying a container.

**Parameters**

*\_\_rhs* An allocator.

**Returns**

\_\_rhs.select\_on\_container\_copy\_construction() or *\_\_rhs*

Returns \_\_rhs.select\_on\_container\_copy\_construction() if that expression is well-formed, otherwise returns *\_\_rhs*

## Author

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