小编jja*_*son的帖子

修改元组c ++向量中的元组

我有一个元组的向量,vector<tuple<int,int>> vector;我想修改它包含的元组之一.

for (std::tuple<int, int> tup : std::vector)
{
    if (get<0>(tup) == k)
    {
        /* change get<1>(tup) to a new value
         * and have that change shown in the vector
         */
    }
}
Run Code Online (Sandbox Code Playgroud)

我不确定如何更改元组的值并将更改反映在向量中.我试过用

get<1>(tup) = v;
Run Code Online (Sandbox Code Playgroud)

但这不会改变向量中元组的值.我怎样才能做到这一点?谢谢.

c++ tuples vector c++11

7
推荐指数
2
解决办法
6531
查看次数

标签 统计

c++ ×1

c++11 ×1

tuples ×1

vector ×1