VS2017 is giving me the error:
It is related to const
keyword. But my class method do not change object variables, so it is constant. m_points
and m_pointsIndex
are
std::vector< std::shared_ptr < DB::Point > > m_points;
std::map<size_t, size_t> m_pointsIndex;
And method is
AcGePoint3d Database::getPoint(size_t index) const
{
AcGePoint3d point;
point.x = m_points[m_pointsIndex[index]]->x();
point.y = m_points[m_pointsIndex[index]]->y();
point.z = m_points[m_pointsIndex[index]]->z();
return point;
}
All my data are stored in SQLite database. All objects reference each other using ID as FOREIGN KEY.
In the application I store all my points in std::vector
for easy looping. And bind ID from SQLite to vector index with std::map
.
In getPoint(size_t index)
method, index are point ID in SQLite database. I convert database id to vector index with m_pointsIndex[index]
and find point in m_points
using it. From point I get x, y and z coordinates and create new point to return. So I don't modify any member variables. So why method can't be constant?