std::get(std::tuple)
来自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< std::size_t I, class... Types > typename std::tuple_element<I, tuple<Types...> >::type& |
(1) | (C++11 起) |
| template< std::size_t I, class... Types > typename std::tuple_element<I, tuple<Types...> >::type&& |
(2) | (C++11 起) |
| template< std::size_t I, class... Types > typename std::tuple_element<I, tuple<Types...> >::type const& |
(3) | (C++11 起) |
提取
Ithelement元素的元组。 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.
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)参考
2) 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.
You can help to correct and verify the translation. Click here for instructions.
rvalue引用
3) 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.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 例外
[编辑] 为例
#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"; }
Output:
(1, Foo, 3.14)
[编辑] 另请参阅
accesses an element of an array (函数模板) | |
| (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. (函数模板) |