Boost logo

Geometry :

Subject: [ggl] distance and reversible
From: Barend (barend)
Date: 2009-05-05 09:56:03


Hi Bruno,

> Hi Barend,
>
> I see the problem but I'm not sure to understand the solution of using
> a copy constructor taking a reverse strategy.
>
> Wouldn't it be better to request that a "reverse" metafunction is
> implemented for each strategy rather than a constructor? This way, you
> can just pass "(typename reverse<S>::type)()" to the reversed
> algorithm.
>
>
The reverse metafunction is a good idea. It however needs to copy its
arguments. I wrote "copy constructor" but now that I write this mail I
realize that it is not, it is an overloaded constructor.

Users can call a strategy with a number of arguments. For example the
haversine formula (sphere great distance calculation):

haversine(double r = constants::average_earth_radius)

So r can be anything there. The distance function does not know about
that. So I thought a templated copy constructor could solve that.

e.g.
class haversine
{
   // normal constructor
   haversine(double r = constants::average_earth_radius) : m_radius(r) {}

   // "reverse type constructor"
   explicit haversine(const strategy::reverse<haversine>::type& instance)
   {
       this->m_radius = instance.radius;
   }
}
or something like that.

> - Will this constructor be used implicitly or explicitly?
> - If used implicitly, where will the conversion occur exactly?
> - If used explicitly, how do you obtain the type of the reversed strategy?
>
I think it will be used explicitly.

Regards, Barend


Geometry list run by mateusz at loskot.net