0

I'm trying to use boost::polygon with boost::multiprecision to calculate polygon differences but no matter how i try to combine the two, i'm always getting compiler errors like

assigning to 'long double' from incompatible type 'boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<0, 0, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, std::allocator<unsigned long long>>, boost::multiprecision::et_off>'

in

https://github.com/boostorg/polygon/blob/develop/include/boost/polygon/detail/polygon_arbitrary_formation.hpp#L401

and similar places when trying to read back the results:

using DifferenceResults = std::vector<gtl::polygon_with_holes_data<ValueType>>;
DifferenceResults differenceResult;
result.value().get<DifferenceResults>(differenceResult);

Here's what i tried.

Am i doing this right? I tried different things for coordinate_traits but at the end it looks like the types and expressions used in the lazy functions like evalAtXforYlazy refuse to support this.

It compiles fine without multiprecision.

I also tried to modify polygon_arbitryry_formation.hpp and added explicit casts wherever needed which was promising at first but at the end lead me to overload resultion problems here which originate here.

I further tried to replace boost.multiprecision with MPIR but they don't even have explicit cast operators but just member functions for conversions which would be even less compatible with evalAtXforYlazy and others.

What am i doing wrong?

jesses
  • 559
  • 3
  • 15
  • From the error, it is apparent that the value expected is a `long double` but you are trying to pass a `boost::multiprecision::number<>`. This conversion is not done implicitly so you need to explicitly cast the value like this: `static_cast(some_multiprecision_var)` – Ruks Jul 05 '21 at 09:18
  • @Ruks What implicit conversion in my example godbolt are you referring to? I think all the implicit conversions happen inside the boost.polygon code and i hoped that i'm doing something wrong so that the code which doesn't convert explicitely (it's mostly the functions with "lazy" in their name) wouldn't be called in the first place. Otherwise i'd maybe conclude that boost.polygon doesn't support multiprecision in the way i'm trying to use it (with polygon_with_holes_data results). – jesses Jul 05 '21 at 09:58

0 Answers0