Make closest_points_first work for all point types #41962
Merged
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.
Summary
SUMMARY: None
Purpose of change
Previously we had separate functions
closest_points_first
andclosest_tripoints_first
. We'd like to extend this functionality tocoord_point
, but it's easier to do if both the raw underlying functions have the same name (so the generic wrapper can be the same).Describe the solution
Rename
closest_tripoints_first
toclosest_points_first
(they are chosen between based on overload resolution), and add a wrapper to allowcoord_point
to be used similarly.Describe alternatives you've considered
Could have made one templatized function, rather than the current situation where we have various wrapper functions and a single implementation of the algorithm. But I didn't want to move the implementation into a header when it wasn't already there, and the wrapper should be pretty fast since it's basically just doing a
malloc
+memcpy
+free
(and the wrapped function is already doing multiple allocations).Testing
Added a new unit test.
Additional context
A chunk of #41693.