std::get(std::array)
Материал из 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. |
| template<size_t I, class T, size_t N > T& get( array<T,N>& a ); |
(1) | (начиная с C++11) |
| template<size_t I, class T, size_t N > T&& get( array<T,N>&& a ); |
(2) | (начиная с C++11) |
| template<size_t I, class T, size_t N > const T& get( const array<T,N>& a ); |
(3) | (начиная с C++11) |
Извлекает элемент
Ith элемент из массива. Original:
Extracts the
Ith element element from the array. 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.
I должно быть целое значение в диапазоне [0, N). Это требование во время компиляции, а не at() или operator[]().Original:
I must be an integer value in range [0, N). This is enforced at compile time as opposed to at() or 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.
Содержание |
[править] Параметры
| a | - | массив, содержимое которого нужно извлечь
Original: array whose contents to extract The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[править] Возвращаемое значение
1)Ссылка на
2) Ith элемент a.Original:
Reference to the
Ith element of a.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.
RValue ссылкой на
3) Ith элемент a, если элемент имеет именующее ссылочного типа, в этом случае именующее ссылка возвращается.Original:
Rvalue reference to the
Ith element of a, unless the element is of lvalue reference type, in which case lvalue reference is returned.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.
Const ссылкой на
Ith элемент a.Original:
Const reference to the
Ith element of a.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.
[править] Исключения
[править] Пример
#include <iostream> #include <array> int main() { std::array<int, 3> arr; // set values: std::get<0>(arr) = 1; std::get<1>(arr) = 2; std::get<2>(arr) = 3; // get values: std::cout << "(" << std::get<0>(arr) << ", " << std::get<1>(arr) << ", " << std::get<2>(arr) << ")\n"; }
Вывод:
(1, 2, 3)
[править] См. также
| предоставляет доступ к указанному элементу (public функция-член) | |
| предоставляет доступ к указанному элементу с проверкой индекса (public функция-член) | |
| кортежа доступ к указанным элементом Original: tuple accesses specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон функции) | |
| (C++11) |
доступ к элементу pair Original: accesses an element of a pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон функции) |