std::allocate_shared – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <memory> |
||
|
|
||
Erzeugt ein Objekt vom Typ T und wickelt es in einem std::shared_ptr mit args als Parameter-Liste für den Konstruktor T .
Original:
Constructs an object of type T and wraps it in a std::shared_ptr using args as the parameter list for the constructor of T.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Alle Speicherzuweisung erfolgt über eine Kopie des alloc, die die Allocator Anforderungen erfüllt .
Original:
All memory allocation is done using a copy of alloc, which satisfies the Allocator requirements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| alloc | - | The Allocator to use.
|
| args... | - | Liste der Argumente, mit denen eine Instanz Original: list of arguments with which an instance of The text has been machine-translated via Google Translate. |
Rückgabewert
std::shared_ptr einer Instanz des Typs T .
Original:
std::shared_ptr of an instance 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
Kann die Ausnahmen von Alloc::allocate() oder aus dem Konstruktor T geworfen werfen .
Original:
Can throw the exceptions thrown from Alloc::allocate() or from the constructor of T.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Notes
Diese Funktion Speicher für die T-Objekt und für die shared_ptr der Kontrolle Block mit einem einzigen Speicherzuweisung. Im Gegensatz dazu führt die Erklärung std::shared_ptr<T> p(new T(Args...)) zwei Speicherzuordnungen, die unnötigen Overhead entstehen können .
Original:
This function allocates memory for the T object and for the shared_ptr's control block with a single memory allocation. In contrast, the declaration std::shared_ptr<T> p(new T(Args...)) performs two memory allocations, which may incur unnecessary overhead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Eine Kopie alloc wird als Teil des Steuerblocks gespeichert, so dass es verwendet werden, um es einmal deallocate gemeinsamen und schwacher Referenzzählung Null erreicht werden .
Original:
A copy of alloc is stored as part of the control block so that it can be used to deallocate it once both shared and weak reference counts reach zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.