Closed andreasdr closed 5 years ago
In some cases constness might be relevant, but only in a few. If unsure ask.
@andreasdr does that only concern the STL Vector and Map?
It is about every STL container.
Checked it - grep -Enr '>\* ([A-Za-Z]+::){0,1}get[[:upper:]]' src/tdme/
It concerns array, vector, and map.
You can search the containers separately: The lines where pointers to STL containers are return values of getter methods
STL vector
grep -Enr 'vector<[A-Za-z0-9*&]+>\* ([A-Za-Z]+::){0,1}get[[:upper:]]' src/tdme/
STL map
grep -Enr 'map<[A-Za-z0-9*&]+, *[A-Za-z0-9*&]+>\* ([A-Za-Z]+::){0,1}get[[:upper:]]' src/tdme/
STL array
grep -Enr 'array<[A-Za-z0-9*&_]+, *[0-9]+>\* ([A-Za-Z]+::){0,1}get[[:upper:]]' src/tdme/
Looks good. Thank you. I am closing this issue.
There seem to be some getters that return pointers of STL containers like vector and map. As long as the container is always backed and the method never returns nullptr I like to have it changed to returning references as this seems to be the most common practice.
You can see those methods by using the following grep queries
Please be careful though as assignments then means copying if not using reference operator like:
In most cases you do not want:
auto vertices = group->getVertices();
But:auto& vertices = group->getVertices();
Thanx @mahula