Espaços nominais
Variantes
Acções

<div class="t-tr-text">operador<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">, Operador<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[]

Da cppreference.com
< cpp‎ | memory‎ | new

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
Gerenciamento de memória dinâmica
Gerenciamento de memória de baixo nível
Alocadores
Original:
Allocators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Uninitialized armazenamento
Original:
Uninitialized storage
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ponteiros inteligentes
Original:
Smart pointers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(obsoleta)
(C++11)
Apoio a coleta de lixo
Original:
Garbage collection support
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
C Library
Original:
C Library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Gerenciamento de memória de baixo nível
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator newoperator new[]
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Objetos
Original:
Objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <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)
Aloca solicitado número de bytes. Estas funções de alocação são chamados por novos-expressões para alocar memória em que novo objeto, então, ser inicializado.
Original:
Allocates requested number of bytes. These allocation functions are called by novos-expressões 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.
1-2)
Aloca count bytes de armazenamento gratuito. Chama o ponteiro de função retornado por std::get_new_handler em caso de falha e repete tentativas de alocação de até novo manipulador não retornar ou se torna um ponteiro nulo, momento em que joga 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.
3-4)
Mesmo que 1-2, mas retorna um ponteiro nulo quando 1-2 jogaria std::bad_alloc
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.
5-6)
não faz nada, ptr retornos. Essas versões são chamados por expressão nova que construir objetos no armazenamento previamente alocado.
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.

Índice

[editar] Substituindo e sobrecarga

As versões 1-4) são implicitamente declarado em cada unidade de tradução, mesmo se o cabeçalho <new> não está incluído. Estas funções são' substituível: a fornecida pelo usuário função não-membro com a mesma assinatura substitui a versão implícita. No máximo uma substituição pode ser fornecido para cada uma das quatro funções de alocação implícitas. Além disso, o programa pode definir versões de membro de classe destas funções ou definir funções de alocação com assinaturas diferentes (exceto que ele não está autorizado a substituir (5-6) versões da função de alocação). A assinatura adicionado deve se parecer com o seguinte, onde count é o número de bytes para alocar e placement_params são os parâmetros fornecidos para a expressão 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.
void* operator new  (size_t count/*, placement_params*/);
for the new version
void* operator new[](size_t count/*, placement_params*/);
for the new[] version
A função de distribuição pode ser substituído / sobrecarregado de duas formas:
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.
'No escopo global': a fim de chamá-lo, a assinatura das funções de alocação sobrecarregadas deve ser visível no local de distribuição, exceto para as funções de alocação declaradas implicitamente padrão. Esta função de distribuição irá ser utilizado para todas as alocações com os parâmetros correspondentes do programa actual
Original:
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 program
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
'No âmbito local': o operator new sobrecarregado deve ser função de membro estático público da classe. Esta função de alocação será usado apenas para alocações dessa classe em particular.
Original:
in the local scope: the overloaded operator new must 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.
Durante a compilação, cada expressão new olha para o nome de função de alocação adequada de primeiro lugar no escopo da classe e depois que no âmbito global. Ele pode ser instruído a pular o primeiro passo chamando new como ::new. Note que, como por sobrecarga regras, quaisquer funções de alocação declarou em escopo de classe esconde todas as funções de alocação global. Para mais informações, consulte NJ expressão. Note que não é possível colocar função de alocação em um espaço.
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 sobrecarga regras, any allocation functions declared in class scope hides all global allocation functions. For more information see NJ expressão. 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.

[editar] Parâmetros

count -
número de bytes para alocar
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 -
ponteiro para uma área de memória para inicializar o objeto a
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.

[editar] Valor de retorno

1-4)
ponteiro para a área de memória alocada
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.

5-6) ptr

[editar] Exceções

1-2)
joga std::bad_alloc em caso de falha ao alocar memória
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.
3-6)
noexcept specification:  
noexcept
  (desde C++11)

[editar] Veja também

funções desalocação
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.

(função) [edit]
obtém o manipulador de corrente de novo
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.

(função) [edit]
registra um novo manipulador
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.

(função) [edit]
Obtém o armazenamento não inicializado
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.

(função)
aloca memória
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.

(função)