Since my post from yesterday got down voted, here again, with just the minimal example and my questions.
#include <set>
#include <algorithm>
using namespace std;
class dummy
{
public:
dummy(int x)
: test(x)
{}
bool operator()(const int &a) const
{
return false;
}
protected:
int test;
};
void foo()
{
// Determine the bounding box.
multiset<float> test;
test.insert(3.5);
multiset<float>::iterator itVertex = test.begin();
multiset<int> workset;
workset.insert(3);
for (itVertex = test.begin(); itVertex != test.end(); itVertex++)
{
multiset<int>::iterator itEnd = remove_if(workset.begin(), workset.end(), dummy(3));
}
}
I've tested the example on the two machines: on Linux (Ubuntu 16.04, g++ 5 and 6) I get the previously described error:
/usr/include/c++/5/bits/stl_algo.h:868:23: error: assignment of read-only location ‘__result.std::_Rb_tree_const_iterator<_Tp>::operator*()’ __result = _GLIBCXX_MOVE(__first);
On Windows 7 Visual Studio 2008 it compiles fine.
I've also checked out the duplicates, yet they fail to describe the case where it works on Windows but does not on Linux.
So why does it compile fine on Windows? Why not on Linux? I understand how I can fix the problem itself, but as this is external code, I don't want to edit the code itself if not necessary.