Improved Variant support

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Improved Variant support

Adam Wulkiewicz

Currently the use of Variants (and in general run-time Geometries) can be problematic. It's because if Variant objects are passed into an algorithm the code for all possible combinations of types is generated which results in a compile-time error. Example:

within(pt, poly); // compiles
//within(poly, pt); // fails - not implemented

boost::variant<pt_t, poly_t> v1, v2;
within(v1, v2); // does not compile

The above code doesn't compile because the code calling within(poly, pt) is generated by the compiler.

I prepared a PR changing it:

With this change the above call for variants compiles and runs. Furthermore the following code compiles and throws an exception.

v1 = poly;
v2 = pt;
within(v1, v2); // compiles but throws

Does someone have something against this change?


Geometry mailing list
[hidden email]