Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.polygon.voronoi] [Boost.multiprecision] higher precision voronoi
From: John Maddock (boost.regex_at_[hidden])
Date: 2014-03-17 05:02:06


> I'm attempting to following the http://www.boost.org/doc/libs/1_53_0_beta1/libs/polygon/doc/voronoi_advanced_tutorial.htm
> to compile boost::polygon::voronoi using 64 bit integer input. I'm using the boost::multiprecision library to do so.
> Using boost version 1.53 and Microsoft Visual Studio 2012.
>
> The error message is:
> 1>d:\workspace\movingboundary\boost_1_53_0\boost\polygon\detail\voronoi_robust_fpt.hpp(60): error C2665: 'sqrt' : none of the 3 overloads could convert all the argument types
> 1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\math.h(588): could be 'long double sqrt(long double)'
> 1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\math.h(540): or 'float sqrt(float)'
> 1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\math.h(127): or 'double sqrt(double)'
> 1> while trying to match the argument list '(const boost::multiprecision::detail::expression<tag,Arg1,Arg2,Arg3,Arg4>)'
> 1> with
> 1> [
> 1> tag=boost::multiprecision::detail::multiplies,
> 1> Arg1=boost::multiprecision::detail::expression<boost::multiprecision::detail::multiplies,boost::multiprecision::detail::expression<boost::multiprecision::detail::plus,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,void,void>,boost::multiprecision::detail::expression<boost::multiprecision::detail::plus,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multi
precision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,void,void>,void,void>,
> 1> Arg2=boost::multiprecision::detail::expression<boost::multiprecision::detail::plus,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,boost::multiprecision::detail::expression<boost::multiprecision::detail::multiply_immediates,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<48>>,void,void>,void,void>,
> 1> Arg3=void,
> 1> Arg4=void
>
> == reference line is
> template <typename T>
> T get_sqrt(const T& that) {
> return (std::sqrt)(that); //<-- line 60
> }

It's a conceptual issue: polynomial is calling std::sqrt, but there is
no overload of sqrt for multiprecision types in that namespace: to place
them there would actually be mal-formed according to the std.

Had polygon been coded like this:

template <typename T>
T get_sqrt(const T& that) {
    using std::sqrt;
    return (sqrt)(that); // ADL is now active
}

Then the correct overload would have been found.

One possible workaround would be to provide an overload of get_sqrt but
that would be hard to do in the presence of expression templates :-(
Turning them off in the number type you're using would make life much
easier, or else I can help with providing expression-template aware
overloads.

I'd be interested to hear from polygon's authors as to why the library
was coded that way, and whether there's any reason not to move to
ADL-aware code.

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net