Return by reference and const overloads #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!