Содержание
Параметр Parameter | Описание Description |
---|---|
Type Type | Тип данных элемента для сохранения в initializer_list . The element data type to be stored in the initializer_list . |
Примечания Remarks
initializer_list можно создать при помощи списка заключенного в фигурные скобки инициализатора: An initializer_list can be constructed using a braced initializer list:
компилятор преобразует списки заключенного в фигурные скобки инициализатора с однородными элементами в initializer_list каждый раз, когда сигнатуре функции требуется initializer_list . The compiler transforms braced initializer lists with homogeneous elements into an initializer_list whenever the function signature requires an initializer_list . Дополнительные сведения об использовании initializer_list см. в разделе Единообразная инициализация и делегирование конструкторов For more details on using initializer_list , see Uniform Initialization and Delegating Constructors
Конструкторы Constructors
Конструктор Constructor | Описание Description |
---|---|
initializer_list initializer_list | Создает объект типа initializer_list . Constructs an object of type initializer_list . |
Определения типов Typedefs
Имя типа Type name | Описание Description |
---|---|
value_type value_type | Тип элементов в initializer_list . The type of the elements in the initializer_list . |
ссылка reference | Тип, предоставляющий ссылку на элемент в initializer_list . A type that provides a reference to an element in the initializer_list . |
const_reference const_reference | Тип, предоставляющий постоянную ссылку на элемент в initializer_list . A type that provides a constant reference to an element in the initializer_list . |
size_type size_type | Тип, представляющий количество элементов в initializer_list . A type that represents the number of elements in the initializer_list . |
iterator iterator | Тип, предоставляющий итератор для initializer_list . A type that provides an iterator for the initializer_list . |
const_iterator const_iterator | Тип, предоставляющий постоянный итератор для initializer_list . A type that provides a constant iterator for the initializer_list . |
Функции-члены Member functions
Функция Member Member function | Описание Description |
---|---|
begin begin | Возвращает указатель на первый элемент в initializer_list . Returns a pointer to the first element in an initializer_list . |
end end | Возвращает указатель на позицию, следующую за последним элементом в initializer_list . Returns a pointer to one past the last element in an initializer_list . |
size size | Возвращает количество элементов в контейнере initializer_list . Returns the number of elements in the initializer_list . |
Требования Requirements
Заголовок: Header:
Пространство имен: std Namespace: std
initializer_list::begin initializer_list::begin
Возвращает указатель на первый элемент в initializer_list . Returns a pointer to the first element in an initializer_list .
Возвращаемое значение Return Value
Указатель на первый элемент initializer_list . A pointer to the first element of the initializer_list . Если список пуст, указателем будет одинаковым для начала и конца списка. If the list is empty, the pointer is the same for the beginning and end of the list.
Примечания Remarks
initializer_list::end initializer_list::end
Возвращает указатель на позицию, следующую за последним элементом в initializer list . Returns a pointer to one past the last element in an initializer list .
Возвращаемое значение Return Value
Указатель на позицию, следующую за последним элементом в списке. A pointer to one past the last element in the list. Если список пуст, он идентичен указателю на первый элемент в списке. If the list is empty, this is the same as the pointer to the first element in the list.
initializer_list::initializer_list initializer_list::initializer_list
Создает объект типа initializer_list . Constructs an object of type initializer_list .
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
Началь First | Положение первого элемента в диапазоне копируемых элементов. The position of the first element in the range of elements to be copied. |
Последняя Last | Положение первого элемента после диапазона копируемых элементов. The position of the first element beyond the range of elements to be copied. |
Примечания Remarks
Объект initializer_list основан на массиве объектов указанного типа. An initializer_list is based on an array of objects of the specified type. При копировании initializer_list создается второй экземпляр списка, указывающий на те же объекты; базовые объекты не копируются. Copying an initializer_list creates a second instance of a list pointing to the same objects; the underlying objects are not copied.
Пример Example
initializer_list::size initializer_list::size
Возвращает количество элементов в списке. Returns the number of elements in the list.
Возвращаемое значение Return Value
Количество элементов в списке. The number of elements in the list.
This type is used to access the values in a C++ initialization list, which is a list of elements of type const T .
Objects of this type are automatically constructed by the compiler from initialization list declarations, which is a list of comma-separated elements enclosed in braces:
Notice though that this template class is not implicitly defined and the header shall be included to access it, even if the type is used implicitly.
initializer_list objects are automatically constructed as if an array of elements of type T was allocated, with each of the elements in the list being copy-initialized to its corresponding element in the array, using any necessary non-narrowing implicit conversions.
The initializer_list object refers to the elements of this array without containing them: copying an initializer_list object produces another object referring to the same underlying elements, not to new copies of them (reference semantics).
The lifetime of this temporary array is the same as the initializer_list object.
Constructors taking only one argument of this type are a special kind of constructor, called initializer-list constructor. Initializer-list constructors take precedence over other constructors when the initializer-list constructor syntax is used: