I tried to overload (c)begin/(c)end functions for a class so as to be able to call c++11 range-based for loop.
It works in most of the cases, but I don't manage to understand and solve one :
for (auto const& point : fProjectData->getPoints()){ ... }
This line returns error : Error C2662: 'MyCollection<T>::begin' : cannot convert 'this' pointer from 'const MyCollection' to 'MyCollection<T> &'
because fProjectData is a const pointer. If I make it non-const, it does work. I don't understand why, considering that cbegin() & cend() are developped with exactness as begin() & end() functions.
Any ideas ? Thanks
Aucun commentaire:
Enregistrer un commentaire