开发者

Expanding an std::tuple

开发者 https://www.devze.com 2023-02-16 19:23 出处:网络
Let\'s say I 开发者_JAVA技巧have a C++0x tuple: tuple<int,int,int> t(1,2,3); Now I can do the following to extract the elements of t:

Let's say I 开发者_JAVA技巧have a C++0x tuple:

tuple<int,int,int> t(1,2,3);

Now I can do the following to extract the elements of t:

int i,j,k;
make_tuple<int&,int&,int&>(i,j,k) = t;

Is there any less verbose way of achieving this? I know about the get<0>(t) syntax; it is not what I am after.


You can use tie for that:

std::tie(i, j, k) = t;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号