I am trying to combine two set to one set, but when I use the simplest example, a error:assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' the code is:
set<int> a;
set<int> b;
int x[4] = {0,1,2,3};int y[5] = {1,2,4,6,9};
a.insert(x,x+4);
b.insert(y,y+5);
set<int> c;
set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin());
So am I writing wrong? What should I do if I want to merge two set and use a new set to contain the elements?
The error calls from this line: set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin());