My code works okay on my linux. Today when I was trying to compile it and test it on my mac, I got an segv error. And later I changed it to another method (not using erase
), the error is gone. I guess that I must have done something wrong in using c++ erase
. Any ideas?
Before: (Why this one is not working now?)
vector<point> line::internalPoints() const
{
vector<point> pts = points();
pts.erase(pts.begin());
pts.erase(pts.end());
return pts;
}
After:
vector<point> line::internalPoints() const
{
vector<point> pts;
vector<point> ptsTmp = points();
for (int i = 1; i < ptsTmp.size()-1; ++i)
{
pts.push_back(ptsTmp[i]);
}
return pts;
}