Open pr0g opened 1 year ago
I believe the reason the build failed for this before was the minimum required version of CMake (3.12
) did not support FetchContent
. I've bumped this to 3.15
and I think it should now work correctly (but again merging this as-is likely isn't a good idea, I was just interested if this alternative API might be useful in certain situations). Thanks!
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!