Annex D (normative) Compatibility features [depr]

D.11 Temporary buffers [depr.temporary.buffer]

The header <memory> has the following additions:

namespace std {
  template <class T>
    pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
  template <class T>
    void return_temporary_buffer(T* p);
}

template <class T> pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;

Effects: Obtains a pointer to uninitialized, contiguous storage for N adjacent objects of type T, for some non-negative number N. It is implementation-defined whether over-aligned types are supported ([basic.align]).

Remarks: Calling get_­temporary_­buffer with a positive number n is a non-binding request to return storage for n objects of type T. In this case, an implementation is permitted to return instead storage for a non-negative number N of such objects, where N != n (including N == 0). [Note: The request is non-binding to allow latitude for implementation-specific optimizations of its memory management. end note]

Returns: If n <= 0 or if no storage could be obtained, returns a pair P such that P.first is a null pointer value and P.second == 0; otherwise returns a pair P such that P.first refers to the address of the uninitialized storage and P.second refers to its capacity N (in the units of sizeof(T)).

template <class T> void return_temporary_buffer(T* p);

Effects: Deallocates the storage referenced by p.

Requires: p shall be a pointer value returned by an earlier call to get_­temporary_­buffer that has not been invalidated by an intervening call to return_­temporary_­buffer(T*).

Throws: Nothing.