list initialization
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. |
<metanoindex/>
Inicializa um objeto de braced-init-lista
Original:
Initializes an object from braced-init-list
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.
Sintaxe
T object { arg1, arg2, ... };
|
(1) | ||||||||
T { arg1, arg2, ... };
|
(2) | ||||||||
new T { arg1, arg2, ... };
|
(3) | ||||||||
return { arg1, arg2, ... } ;
|
(4) | ||||||||
function( { arg1, arg2, ... } ) ;
|
(5) | ||||||||
object[ { arg1, arg2, ... } ] ;
|
(6) | ||||||||
T( { arg1, arg2, ... } )
|
(7) | ||||||||
Class { T member = { arg1, arg2, ... }; };
|
(8) | ||||||||
Class::Class() : member{arg1, arg2, ...} {...
|
(9) | ||||||||
T object = {arg1, arg2, ...};
|
(10) | ||||||||
Explicação
Lista de inicialização é realizada nas seguintes situações:
Original:
List initialization is performed in the following situations:
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)
inicialização de uma variável chamada com uma lista cinta-fechado de expressões ou listas aninhadas (preparou-init-list)
Original:
initialization of a named variable with a brace-enclosed list of expressions or nested lists (braced-init-list)
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.
2)
inicialização de um temporário sem nome com uma lista apoiou-init
Original:
initialization of an unnamed temporary with a braced-init-list
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)
inicialização de um objeto com duração de armazenamento dinâmico, com uma expressão nova, onde o inicializador é uma cinta-init-lista
Original:
initialization of an object with dynamic storage duration with a new-expression, where the initializer is a brace-init-list
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.
4)
em comunicado
return com braced-init-lista usada como a expressão de retornoOriginal:
in a
return statement with braced-init-list used as the return expressionThe 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)
em uma expressão chamada de função, com preparei-init-list usado como um argumento
Original:
in a function call expression, with braced-init-list used as an argument
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.
6)
em uma expressão subscrito com um operador definido pelo usuário []
Original:
in a subscript expression with a user-defined operator[]
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.
7)
em uma expressão de conversão funcional ou outro inicialização-direta, com preparei-init-lista usado como o argumento do construtor
Original:
in a functional cast expression or other direct-initialization, with braced-init-list used as the constructor argument
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.
8)
em um inicializador de membro não-estático de dados
Original:
in a non-static data member initializer
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.
9)
em uma lista de inicializador construtor
Original:
in a constructor initializer list
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.
10)
no lado direito do sinal de igual (semelhante ao cópia de inicialização)
Original:
on the right-hand-side of the equals sign (similar to cópia de inicialização)
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.
Os efeitos da inicialização lista de um objeto de
T tipo são:Original:
The effects of list initialization of an object of type
T are: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.
- Se a lista braced-init-se vazio e
Té um tipo de classe com um construtor padrão, valor de inicialização é realizada.Original:If the braced-init-list is empty andTis a class type with a default constructor, valor de inicialização is performed.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Caso contrário, se
Té um tipo de agregado, inicialização agregada é realizado.Original:Otherwise, ifTis an aggregate type, inicialização agregada is performed.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Caso contrário, se
Té uma especialização de std::initializer_list, um objetostd::initializer_listnovo do mesmo tipo é construído e usado para dirigir-inicializar ou copiar-inicializar o objeto deTtipo, dependendo do contexto.Original:Otherwise, ifTis a specialization of std::initializer_list, a newstd::initializer_listobject of the same type is constructed and used to direct-initialize or copy-initialize the object of typeT, depending on context.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Caso contrário, os constuctors de
Tsão considerados, em duas fases:Original:Otherwise, the constuctors ofTare considered, in two phases:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Todos os construtores que levam std::initializer_list como o único argumento, ou como o primeiro argumento, se os argumentos restantes têm valores padrão, são examinados, e acompanhado por resolução de sobrecarga contra um único argumento do tipo std::initializer_listOriginal:All constructors that take std::initializer_list as the only argument, or as the first argument if the remaining arguments have default values, are examined, and matched by overload resolution against a single argument of type std::initializer_listThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se a etapa anterior não produz uma partida, todos os construtores de
Tparticipar de resolução de sobrecarga em relação ao conjunto de argumentos que consiste nos elementos da braced-lista-init, com a restrição de que apenas conversões de estreitamento são permitidos. Se nesta fase produz um construtor explícito como o melhor para uma cópia de lista de inicialização, compilação falhar (nota, em simples cópia de inicialização, construtores explícitos não são consideradas em todos)Original:If the previous stage does not produce a match, all constructors ofTparticipate in overload resolution against the set of arguments that consists of the elements of the braced-init-list, with the restriction that only narrowing conversions are allowed. If this stage produces an explicit constructor as the best match for a copy-list-initialization, compilation fails (note, in simple copy-initialization, explicit constructors are not considered at all)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click