我有一个元组的向量,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)
但这不会改变向量中元组的值.我怎样才能做到这一点?谢谢.