<div class="t-tr-text">Betreiber<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">operator</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div> new<div class="t-tr-text">, Betreiber<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">, operator</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div> new[]
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>| definiert in Header <new>
|
||
void* operator new ( std::size_t count ); |
(1) | |
void* operator new[]( std::size_t count ); |
(2) | |
void* operator new ( std::size_t count, const std::nothrow_t& ); |
(3) | |
void* operator new[]( std::size_t count, const std::nothrow_t& ); |
(4) | |
void* operator new ( std::size_t, void* ptr ); |
(5) | |
void* operator new[]( std::size_t, void* ptr ); |
(6) | |
Ordnet angeforderte Anzahl von Bytes. Diese Aufteilung Funktionen werden durch new-Ausdrücken rief Speicher, in dem neuen Objekt dann würde initialisiert zuzuordnen .
Original:
Allocates requested number of bytes. These allocation functions are called by new-Ausdrücken to allocate memory in which new object would then be initialized.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1-2)
Ordnet
count Bytes aus freien Speicher. Ruft die Funktion Zeiger von std::get_new_handler bei Ausfall und wiederholt Allokation Versuche, bis neue Handler nicht zurück oder wird ein NULL-Zeiger, zu welcher Zeit wirft std::bad_alloc zurückgegeben .Original:
Allocates
count bytes from free store. Calls the function pointer returned by std::get_new_handler on failure and repeats allocation attempts until new handler does not return or becomes a null pointer, at which time throws std::bad_alloc.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3-4)
Gleich wie 1-2, aber gibt ein NULL-Zeiger, wenn 1-2 std::bad_alloc werfen würde
Original:
Same as 1-2, but returns a null pointer when 1-2 would throw std::bad_alloc
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
5-6)
tut nichts, kehrt
ptr. Diese Versionen werden durch neue Ausdruck, welche Objekte in zuvor zugewiesenen Speicher Konstrukt namens .Original:
does nothing, returns
ptr. These versions are called by new-expression which construct objects in previously allocated storage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Austauschen und Überlastung
Die Versionen 1-4) sind implizit in jeder Übersetzungseinheit deklariert, auch wenn die
<tbody>
</tbody><new> Header ist nicht inbegriffen. Diese Funktionen sind austauschbare: eine vom Benutzer bereitgestellte Nichtmitglied Funktion mit der gleichen Signatur ersetzt die implizite Version. Höchstens ein Ersatz kann jede der vier impliziten Zuordnungsfunktionen vorgesehen sein. Auch können Programm definieren Klassenmember Versionen dieser Funktionen oder definieren Zuordnungsfunktionen mit unterschiedlichen Signaturen (außer, dass es nicht erlaubt zu ersetzen (5-6) Versionen des Zuteilungsfunktion). Die zusätzliche Signatur sollte wie folgt aussehen, wo count Anzahl von Bytes zu vergeben ist und placement_params sind die Parameter zugeführten new Ausdruck:Original:
The versions 1-4) are implicitly declared in each translation unit even if the
<new> header is not included. These functions are replaceable: a user-provided non-member function with the same signature replaces the implicit version. At most one replacement may be provided for each of the four implicit allocation functions. Also, program can define class member versions of these functions or define allocation functions with different signatures (except that it is not permitted to replace (5-6) versions of the allocation function). The added signature should look like the following, where count is number of bytes to allocate and placement_params are the parameters supplied to the new expression:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
void* operator new (size_t count/*, placement_params*/); |
for the new version |
|
void* operator new[](size_t count/*, placement_params*/); |
for the new[] version |
|
Die Zuordnung Funktion ersetzt / überlastet in zweierlei Hinsicht:
Original:
The allocation function can be replaced/overloaded in two ways:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- 'Im globalen Bereich': Um es nennen, die Signatur der überladenen Zuordnungsfunktionen muss sichtbar sein am Ort der Zuweisung, außer implizit deklariert Standardzuordnung Funktionen. Diese Zuordnung Funktion wird für alle Zuweisungen mit entsprechenden Parametern im aktuellen Programm verwendet werdenOriginal:in the global scope: in order to call it, the signature of the overloaded allocation functions must be visible at the place of allocation, except for implicitly declared default allocation functions. This allocation function will be used for all allocations with corresponding parameters in the current programThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 'Im lokalen Bereich': die überladene
operator newmüssen statische öffentliche Member-Funktion der Klasse sein. Diese Zuordnung Funktion wird nur für die Zuweisungen des jeweiligen Klasse verwendet werden .Original:in the local scope: the overloadedoperator newmust be static public member function of the class. This allocation function will be used only for allocations of that particular class.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Während der Kompilierung, sieht jeder
new Ausdruck für eine angemessene Zuteilung Funktionsnamen zunächst in der Klasse Umfang und nach, dass im globalen Bereich. Es kann angewiesen werden, den ersten Schritt, indem Sie new als ::new überspringen. Beachten Sie, dass nach Überlastung Regeln, erklärte der Zuweisung Funktionen im Gültigkeitsbereich der Klasse blendet alle weltweiten Allokation Funktionen. Für weitere Informationen siehe NJ Ausdruck. Beachten Sie, dass es nicht möglich ist, Zuteilungsfunktion in einem Namensraum platzieren .Original:
During compilation, each
new expression looks up for appropriate allocation function's name firstly in the class scope and after that in the global scope. It can be instructed to skip the first step by calling new as ::new. Note, that as per Überlastung Regeln, any allocation functions declared in class scope hides all global allocation functions. For more information see NJ Ausdruck. Note, that it is not possible to place allocation function in a namespace.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| count | - | Anzahl von Bytes, zuzuweisen
Original: number of bytes to allocate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| ptr | - | Zeiger auf einen Speicherbereich, das Objekt an initialisieren
Original: pointer to a memory area to initialize the object at The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rückgabewert
1-4)
Zeiger auf reservierten Speicherbereich
Original:
pointer to allocated memory area
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
5-6) ptr
Ausnahmen
1-2)
wirft std::bad_alloc bei Ausfall Speicher zugewiesen werden
Original:
throws std::bad_alloc on failure to allocate memory
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3-6)
