std::get(std::tuple)
来自cppreference.com
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 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)).原文:
Extracts the
Ith element element from the tuple. I is an integer value in [0, sizeof...(Types)).目录 |
[编辑] 参数
| t | - | 元组的内容提取
|
[编辑] 返回值
1)参考
2) Ith元素t.rvalue引用
3) Ith的t元素,除非该元素是左值引用类型,在这种情况下,左值引用被返回.原文:
Rvalue reference to the
Ith element of t, unless the element is of lvalue reference type, in which case lvalue reference is returned.const引用的
Ith元素t.原文:
Const reference to the
Ith element of t.[编辑] 例外
[编辑] 示例
#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)
[编辑] 另请参阅
访问array的一个元素 (函数模板) | |
| (C++11) |
访问pair的一个元素 (函数模板) |