#include <iostream>
#include <tuple>
int main()
{
int a = 1 ;
double b = 2.2;
int c = 3 ;
double d = 4.4;
std::tuple<int, double, int, double> myTuple;
myTuple = std::tie(a, b, c, d);
std::cout << std::get<0>(myTuple) << " "; // 1
std::cout << std::get<1>(myTuple) << " "; // 2.0
std::cout << std::get<2>(myTuple) << " "; // 3
std::cout << std::get<3>(myTuple) << " "; // 4.0
std::cout << std::endl;
return 0;
}
// Output: 1 2.2 3 4.4
Reference: http://en.cppreference.com/w/cpp/utility/tupleMonday, November 27, 2017
C++11: std::tie() – tuple packing
The function template std::tie() allows you to pack a tuple. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment