'left' is std::vector of std::set for each element in left(which is set), I am trying to do set union operation to another set by iterating over 'left'.
Why is the following code not working. I am trying to do set union of the two sets.
std::vector<std::set<int> > left(num_nodes);
//Both leftv and left are not empty ....there is some code here which fills them.
std::set<int> leftv, dummy;
for(std::set<int>::iterator u = leftv.begin(); u != leftv.end() ;u++){
dummy.insert(v); //v is some integer
std::set_union (left[*u].begin(), left[*u].end(), dummy.begin(), dummy.end(), left[*u].begin());
dummy.clear();
}
Error /usr/include/c++/4.3/bits/stl_algo.h:5078: error: assignment of read-only location ‘__result.std::_Rb_tree_const_iterator<_Tp>::operator* with _Tp = int’