Boost logo

Geometry :

Subject: [ggl] distance and reversible
From: Bruno Lalande (bruno.lalande)
Date: 2009-05-06 05:01:00


Hi Barend,

> 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.

Yep I had understood it wasn't a "real" copy constructor, I see the
idea. I didn't have thought about the problem of copying arguments,
indeed this can only be handled by a runtime function, so a
constructor.

However a metafunction giving the reverse of a strategy is still
needed. I guess you agree with that since you write:

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

so you finally make use of a strategy::reverse<X> metafunction. This
sounds OK to me.

So the reserve of a strategy "s" of type "S" could finally be
constructed like that, if I understand well:

strategy::reverse<S>::type reversed(s);

If we call "RS" the result of strategy::reverse<S>::type, the
constructor invoked is actually RS::RS(const S&). So if you want to
fall into the reverse constructor you wrote, RS must be the same type
as "strategy::reverse<RS>::type", which is the argument type of this
constructor. Which is to say that the strategy::reverse metafunction
must guaranty that, for any X:

strategy::reverse<strategy::reserve<X>::type>::type returns X

Is this requirement is satisfied, I think it will work.

Do you agree with that? Have I correctly understood?

Regards
Bruno


Geometry list run by mateusz at loskot.net