Click here to Skip to main content
15,900,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello. I want to update values in tuples of a list. the tuples in the list contains vertices of a graph and the degree of each vertices. I used igraph library to work on the graph. I wrote the following code. but, the value of tuple in the list d is not changed (I bolded the line that I mean). how can I resolve the problem?
std::list<std::tuple<int, int> >::iterator it;
list<std::tuple<int, int> > d;

it = d.begin();

for (int i=0;i<igraph_vcount(&graph);i++)
{
    tuple<int, int> f1=   it._Ptr[0]._Myval;
    std::get<1>(f1) = static_cast<int>( VECTOR(v)[i]);
    std::advance(it,1);
    }


What I have tried:

I use visual studio 2012.
Posted
Updated 15-Apr-17 9:30am
v6

As far as i remember a tuple is immutable. This means that you cannot change it after creation.
You can use array instead of tuple.

See:
<tuple> - C++ Reference[^]
 
Share this answer
 
v2
The only way to change a value in a tuple is to make a new tuple with the values from the old tuple and the one you want to change and return that.
 
Share this answer
 
Comments
Member 11807654 17-Apr-17 13:54pm    
thanks a lot. you mean that I should remove the old tuple and make a new one?
Dave Kreskowiak 17-Apr-17 19:10pm    
Google for "C++ tuple". There's tons of documentation out there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900