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

# \_\_gnu\_cxx::temporary\_buffer(3cxx)

## NAME

\_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>

## SYNOPSIS

`#include <memory>`

Inherits **std::\_Temporary\_buffer\< \_ForwardIterator, \_Tp \>**.

### Public Types

typedef pointer **iterator**\
 typedef value\_type \* **pointer**\
 typedef ptrdiff\_t **size\_type**\
 typedef \_Tp **value\_type**\

### Public Member Functions

**temporary\_buffer** (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last)\
 Requests storage large enough to hold a copy of \[first,last).  **~temporary\_buffer** ()\
 Destroys objects and frees storage.  iterator **begin** ()\
 As per Table mumble.  iterator **end** ()\
 As per Table mumble.  size\_type **requested\_size** () const\
 Returns the size requested by the constructor; may be \>size().  size\_type **size** () const\
 As per Table mumble.

### Protected Attributes

pointer **\_M\_buffer**\
 size\_type **\_M\_len**\
 size\_type **\_M\_original\_len**\

## Detailed Description

### template\<class \_ForwardIterator, class \_Tp = typename std::iterator\_traits\<\_ForwardIterator\>::value\_type\>

struct \_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>"This class provides similar behavior and semantics of the standard functions get\_temporary\_buffer() and return\_temporary\_buffer(), but encapsulated in a type vaguely resembling a standard container.

By default, a temporary\_buffer\<Iter\> stores space for objects of whatever type the Iter iterator points to. It is constructed from a typical \[first,last) range, and provides the begin(), end(), size() functions, as well as requested\_size(). For non-trivial types, copies of \*first will be used to initialize the storage.

`malloc` is used to obtain underlying storage.

Like get\_temporary\_buffer(), not all the requested memory may be available. Ideally, the created buffer will be large enough to hold a copy of \[first,last), but if size() is less than requested\_size(), then this didn't happen.

## Constructor & Destructor Documentation

### template\<class \_ForwardIterator , class \_Tp = typename std::iterator\_traits\<\_ForwardIterator\>::value\_type\> \_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>::temporary\_buffer (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last)` [inline]`

Requests storage large enough to hold a copy of \[first,last).

### template\<class \_ForwardIterator , class \_Tp = typename std::iterator\_traits\<\_ForwardIterator\>::value\_type\> \_\_gnu\_cxx::temporary\_buffer\< \_ForwardIterator, \_Tp \>::~temporary\_buffer ()` [inline]`

Destroys objects and frees storage.

## Member Function Documentation

### template\<typename \_ForwardIterator , typename \_Tp \> iterator std::\_Temporary\_buffer\< \_ForwardIterator, \_Tp \>::begin ()` [inline]`, ` [inherited]`

As per Table mumble.

### template\<typename \_ForwardIterator , typename \_Tp \> iterator std::\_Temporary\_buffer\< \_ForwardIterator, \_Tp \>::end ()` [inline]`, ` [inherited]`

As per Table mumble.

### template\<typename \_ForwardIterator , typename \_Tp \> size\_type std::\_Temporary\_buffer\< \_ForwardIterator, \_Tp \>::requested\_size () const` [inline]`, ` [inherited]`

Returns the size requested by the constructor; may be \>size().

### template\<typename \_ForwardIterator , typename \_Tp \> size\_type std::\_Temporary\_buffer\< \_ForwardIterator, \_Tp \>::size () const` [inline]`, ` [inherited]`

As per Table mumble.

## Author

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