//遍历输出tuple元素的简洁方式(C++11) //Win32Con17_VS2017_01.cpp #include <iostream> #include <tuple> using namespace std; template<typename... Args> void myprint_impl(tuple<Args...> tup) //泛化版本 { cout << tup._Myfirst._Val << ((tup._Mysize > ) ? ", " : ""); //输出tup的头1项 myprint_impl(tup._Get_rest()); //对除头1项之外的tup递归调用 } template<> void myprint_impl(tuple<> tup) //终止条件 { cout << endl; } int main() { auto t = make_tuple(, 4.67, "Hello", true); myprint_impl(t); //3, 4.67, Hello, 1 system("pause"); ; }