<div class="t-tr-text">opérateur<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">, Opérateur<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[]
De cppreference.com.
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Défini dans l'entête <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) | |
Alloue demandé nombre d'octets. Ces fonctions sont appelées par répartition nouvelles-expressions à allouer de la mémoire dans laquelle nouvel objet sera alors initialisé .
1-2) Original:
Allocates requested number of bytes. These allocation functions are called by nouvelles-expressions 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.
Alloue
3-4) count octets de mémoire libre. Appelle le pointeur renvoyé par la fonction std::get_new_handler en cas d'échec des tentatives d'allocation et répète jusqu'à ce nouveau gestionnaire ne retourne pas ou devient un pointeur NULL, date à laquelle jette std::bad_alloc .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.
Identique à 1-2, mais retourne un pointeur nul lorsque 1-2 serait std::bad_alloc jeter
5-6) 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.
ne fait rien,
ptr rendements. Ces versions sont appelées par la nouvelle expression qui construisent des objets dans le stockage précédemment alloué .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.
Sommaire |
[modifier] Remplacement de la surcharge
Les versions 1-4) sont implicitement déclaré dans chaque unité de traduction, même si l'en-tête
<new> n'est pas inclus. Ces fonctions sont' remplaçable: un fourni par l'utilisateur non membre de fonction avec la même signature remplace la version implicite. Au plus un remplacement peut être prévu pour chacun des quatre fonctions d'allocation implicites. En outre, le programme peut définir les versions de membre de classe de ces fonctions ou de définir des fonctions de répartition avec des signatures différentes (sauf qu'il n'est pas autorisé à remplacer (5-6) versions de la fonction d'allocation). La signature ajoutée devrait ressembler à ce qui suit, où count est le nombre d'octets à allouer et' placement_params sont les paramètres fournis à l'expression new: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 |
|
La fonction d'allocation peut être remplacé / surchargé de deux façons:
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.
- 'Dans la portée globale': pour l'appeler, la signature des fonctions d'allocation de surcharge doit être visible à l'endroit de l'attribution, à l'exception des implicitement déclarés fonctions d'allocation par défaut. Cette fonction d'allocation sera utilisé pour toutes les allocations avec les paramètres correspondants dans le programme actuelOriginal: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. - 'Dans la portée locale': l'
operator newsurchargée doit être statique fonction membre public de la classe. Cette fonction d'allocation ne sera utilisée que pour les allocations de cette catégorie particulière .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.
Lors de la compilation, chaque expression
new lève les yeux pour le nom de la fonction de répartition appropriée d'abord dans le domaine de la classe et après que dans la portée globale. Il peut être chargé de sauter la première étape en appelant new que ::new. Notez que selon surcharge règles, les fonctions d'allocation déclaré dans la portée de classe se cache toutes les fonctions de répartition mondiale. Pour plus d'informations NJ expression voir. Notez qu'il n'est pas possible de placer la fonction d'allocation dans un espace de noms .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 surcharge règles, any allocation functions declared in class scope hides all global allocation functions. For more information see NJ expression. 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.
[modifier] Paramètres
| count | - | nombre d'octets à allouer
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 | - | pointeur vers une zone de mémoire pour initialiser l'objet à
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. |
[modifier] Retourne la valeur
1-4)pointeur de zone de mémoire allouée
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
[modifier] Exceptions
1-2)jette std::bad_alloc en cas d'échec d'allocation de mémoire
3-6)
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.
[modifier] Voir aussi
| fonctions de désallocation Original: deallocation functions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
| (C++11) |
obtient le gestionnaire courant nouveau Original: obtains the current new handler The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |
| enregistre un nouveau gestionnaire Original: registers a new handler The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
| obtient de stockage non initialisée Original: obtains uninitialized storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
| alloue de la mémoire Original: allocates memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |