#include <map> // 使用tuple需要包含的头文件
#include <iostream>
using namespace std;
int main()
{
tuple<int, char, string>tup0(1, 'A', "hello world");
int e1 = tup0.head();// 1
int e2 = tup0.tail().head(); // 'A'
unsigned short cnt = tuple_size(decltype(tup0))::value; // 获取元素个数:3
tuple<char, string> tup1 = tup0.tail();
tuple<double, string> tup2 = make_tuple(1.1, "ABC");
auto d0 = get<0>(tup2);// 1.1
auto d1 = get<1>(tup2);// "ABC"
cout <<typeid(d0).name()<< endl;// 获取元素的数据类型:double
decltype(d0) d2 = d0;// 逆推d0的数据类型,并使用其声明一个变量d0,然后赋值为d0
return 0;
}原文:http://blog.csdn.net/xufeng0991/article/details/42194613