This PR adds a const overload of GetPoint (that returns a const Point*) and updates GetTriangles and GetMap to return a const reference to the underlying data structure as opposed to returning by value (and forcing a copy).
A copy can still be made by not using a const ref variable.
I held off making any further changes to keep the PR small and simple. There are a few more spots that could benefit from const but it's not critical by any means.
Also to reduce duplication in the const/non-const overloads, I used the solution popularized by Scott Meyers in Effective C++ (Item 3) - see https://stackoverflow.com/a/123995/1947066 for details (I'm happy to change this to duplicate the logic in both overloads if you think that is clearer, or add a comment to explain what is being done and why).
Great library and I hope this incredibly minor contribution is helpful,
This PR adds a
const
overload ofGetPoint
(that returns aconst Point*
) and updatesGetTriangles
andGetMap
to return aconst
reference to the underlying data structure as opposed to returning by value (and forcing a copy).A copy can still be made by not using a
const
ref variable.e.g.
I held off making any further changes to keep the PR small and simple. There are a few more spots that could benefit from
const
but it's not critical by any means.Also to reduce duplication in the
const
/non-const
overloads, I used the solution popularized by Scott Meyers in Effective C++ (Item 3) - see https://stackoverflow.com/a/123995/1947066 for details (I'm happy to change this to duplicate the logic in both overloads if you think that is clearer, or add a comment to explain what is being done and why).Great library and I hope this incredibly minor contribution is helpful,
Thanks!