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 is a speculative/demonstrative PR to show how the
poly2tri
API could be potentially improved upon by accepting aspan
ofp2t::Point
instead of astd::vector<p2t::Point*>
.In this case, the
span
implementation is taken from the Guidelines Support Library (GSL) from Microsoft, but it could also usestd::span
if poly2tri was updated to use C++ 20.In my particular use case, I needed to create a vector of
p2t::Point
types, and an additional 'view' vector ofp2t::Point*
. By using aspan
, the semantics of using a vector of pointers remains the same, but you don't need to allocate a new container of pointers, you can just use the original one. You also can avoid having tonew
each point (as is done in thetestbed
example andunittest
project).I realize this is a breaking API change and it's possible there are some downsides I'm not considering, but for my particular use case, it made things a lot cleaner and simpler (and more efficient).
I'd definitely be interested to hear what people think.
Thanks!