◐ Shell
clean mode source ↗

std::allocator::allocate – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

pointer allocate( size_type n, std::allocator<void>::const_pointer hint = 0 );

Ordnet n * sizeof(T) Bytes initialisierten Speicher durch den Aufruf ::operator new(std::size_t), aber es ist nicht angegeben, wann und wie diese Funktion aufgerufen wird. Der Zeiger hint kann zur Lokalität der Referenz darstellen: die Zuweisungseinrichtung, wenn durch die Ausführung unterstützt, wird versuchen, den neuen Speicherblock so nahe wie möglich zu verteilen .. hint

Original:

Allocates n * sizeof(T) bytes of uninitialized storage by calling ::operator new(std::size_t), but it is unspecified when and how this function is called. The pointer hint may be used to provide locality of reference: the allocator, if supported by the implementation, will attempt to allocate the new memory block as close as possible to hint.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parameter

n -

die Anzahl der Objekte, um Speicherplatz für zuzuteilen

Original:

the number of objects to allocate storage for

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

hint -

Zeiger auf eine Speicherstelle in der Nähe

Original:

pointer to a nearby memory location

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Rückgabewert

Zeiger auf das erste Byte eines Speicherblocks geeigneterweise ausgerichtet und ausreichend, um eine Anordnung von Gegenständen vom Typ n T halten .

Original:

Pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of n objects of type T.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ausnahmen

Wirft std::bad_alloc, falls die Zuweisung nicht .

Original:

Throws std::bad_alloc if allocation fails.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Siehe auch

ordnet initialisierten Speicher mit der Zuweisung

Original:

allocates uninitialized storage using the allocator

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(public static Elementfunktion of std::allocator_traits) [edit]