---
name: "__gnu_cxx::new_allocator"
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_cxx::new_allocator/3cxx"
---

# \_\_gnu\_cxx::new\_allocator(3cxx)

An allocator that uses global new, as per C++03 \[20.4.1\].

## NAME

\_\_gnu\_cxx::new\_allocator\< \_Tp \> - An allocator that uses global `new`, as per C++03 \[20.4.1\].

## SYNOPSIS

`#include <ext/new_allocator.h>`

Inherits **std::\_\_new\_allocator\< \_Tp \>**.

### Public Types

typedef std::ptrdiff\_t **difference\_type**\
 typedef **std::true\_type** **propagate\_on\_container\_move\_assignment**\
 typedef std::size\_t **size\_type**\
 typedef \_Tp **value\_type**\

### Public Member Functions

**new\_allocator** (const **new\_allocator** &) noexcept\
 template\<typename \_Tp1 \> **new\_allocator** (const **new\_allocator**\< \_Tp1 \> &) noexcept\
 \_Tp \* **allocate** (size\_type \_\_n, const void \*=static\_cast\< const void \* \>(0))\
 void **deallocate** (\_Tp \*\_\_p, size\_type \_\_n)\

## Detailed Description

### template\<typename \_Tp\>

class \_\_gnu\_cxx::new\_allocator\< \_Tp \>"An allocator that uses global `new`, as per C++03 \[20.4.1\].

This is precisely the allocator defined in the C++ Standard.

- •

  all allocation calls `operator new`

- •

  all deallocation calls `operator delete`

This is a non-standard extension that can be used to guarantee allocation from `new` even if the library has been configured to use a different implementation for `std::allocator`.

**Template Parameters**

*\_Tp* Type of allocated object.

## Author

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