Espaços nominais
Variantes
Ações

list initialization

De cppreference.com

<metanoindex/>

 
 
Linguagem C++
Tópicos gerais
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Controle de fluxo
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Declarações execução condicional
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Instruções de iteração
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ir declarações
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
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.
declaração da função
lambda declaração da função
modelo de função
linha especificador
especificações de exceção (obsoleta)
noexcept especificador (C++11)
Exceções
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
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.
decltype specifier (C++11)
Especificadores
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv especificadores
armazenamento duração especificadores
constexpr especificador (C++11)
auto especificador (C++11)
alignas especificador (C++11)
Inicialização
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literais
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressões
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
representações alternativas
Utilitários
Original:
Utilities
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.
typedef declaration
tipo de alias declaração (C++11)
atributos (C++11)
Conversões
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversões implícitas
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Elenco C-estilo e funcional
Alocação de memória
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
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.
Classe propriedades específicas de função
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funções membro especiais
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modelos
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
modelo de classe
modelo de função
especialização de modelo
pacotes de parâmetros (C++11)
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.
Assembly embutido
 
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.

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.
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.
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.
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.
4)
em comunicado return com braced-init-lista usada como a expressão de retorno
Original:
in a return statement with braced-init-list used as the return expression
The text has been machine-translated via Google Translate.
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.
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.
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.
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.
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.
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.
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.
  • 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 and T is 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 é uma especialização de std::initializer_list, um objeto std::initializer_list novo do mesmo tipo é construído e usado para dirigir-inicializar ou copiar-inicializar o objeto de T tipo, dependendo do contexto.
    Original:
    Otherwise, if T is a specialization of std::initializer_list, a new std::initializer_list object of the same type is constructed and used to direct-initialize or copy-initialize the object of type T, 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 T são considerados, em duas fases:
    Original:
    Otherwise, the constuctors of T are 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_list
    Original:
    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_list
    The 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 T participar 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 of T participate 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