Пространства имён
Варианты
Действия

std::get(std::tuple)

Материал из cppreference.com

 
 
 
std::tuple
Член функций
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple::tuple
tuple::operator=
tuple::swap
Не являющиеся членами функций
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
make_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
Вспомогательные классы
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size
tuple_element
uses_allocator
ignore
 
template< std::size_t I, class... Types >

typename std::tuple_element<I, tuple<Types...> >::type&

    get( tuple<Types...>& t );
(1) (начиная с C++11)
template< std::size_t I, class... Types >

typename std::tuple_element<I, tuple<Types...> >::type&&

    get( tuple<Types...>&& t );
(2) (начиная с C++11)
template< std::size_t I, class... Types >

typename std::tuple_element<I, tuple<Types...> >::type const&

    get( const tuple<Types...>& t );
(3) (начиная с C++11)
Извлекает элемент Ith элемент из кортежа. I целое значение в [0, sizeof...(Types)).
Original:
Extracts the Ith element element from the tuple. I is an integer value in [0, sizeof...(Types)).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Содержание

[править] Параметры

t -
кортежа, содержимое которого нужно извлечь
Original:
tuple 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)
Ссылка на Ith элемент t.
Original:
Reference to the Ith element of t.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
RValue ссылкой на Ith элемент t, если элемент имеет именующее ссылочного типа, в этом случае именующее ссылка возвращается.
Original:
Rvalue reference to the Ith element of t, 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.
3)
Const ссылкой на Ith элемент t.
Original:
Const reference to the Ith element of t.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[править] Исключения

noexcept-спецификация:  
noexcept
  (начиная с C++11)

[править] Пример

#include <iostream>
#include <string>
#include <tuple>
 
int main()
{
    auto t = std::make_tuple(1, "Foo", 3.14);
    std::cout << "(" << std::get<0>(t) << ", " << std::get<1>(t)
              << ", " << std::get<2>(t) << ")\n";
}

Вывод:

(1, Foo, 3.14)

[править] См. также

accesses an element of an array
(шаблон функции) [edit]
доступ к элементу 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.

(шаблон функции) [edit]