Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] memory layout of fusion::vector vs boost::tuple/boost::array
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-10-08 14:44:47


On Oct 6, 5:33 pm, Joel de Guzman <j..._at_[hidden]> wrote:
> On 10/7/2010 3:53 AM, alfC wrote:
>
> > Hi,
>
> >   I am trying to convert a boost::array into a fusion::vector.
> > reinterpreting the memory from boost::array. It works for tuples but
> > not fusion::vector, why is that. Is there a way to make it work? ( I
> > was hoping that the memory layout is the same to make conversion from
> > one to the other very easy.)
>
> Don't do that. It will *never* be guaranteed to work even if it works
> now. The memory layout of fusion::vector is an internal implementation
> detail and can change anytime.

The question is: is it guaranteed for boost::tuples<double,
double, ... >?
(it seems so, just by the PODness of tuples of PODs in its stated
design.) If so, then it is a *feature* of boost::tuple.
Fusion, which is supposed to be an extension of boost::tuple (or at
least that was my understanding), lost such feature that I could
exploit.

The situation is the following: quantity<U,T> because it claims that
has no runtime cost, this is like saying that it can be interpreted as
its underlying type T (e.g. double). All numerical routines that I am
using take fixed arrays of double or basically boost::arrays. The
analogy is perfect if I use tuples because I can reinterpret them as
arrays back *and* forth without copying anything or adding any
additional code.

Since I can't do this with fusion::vector then I will have to use
boost::tuples. This will be a pain in it self because then I will have
to manually code MPL to tuples generation and loose the nice
fusion::transforms. It seem I am out of luck, and just fallen in a
crack between tuples and fusion.

There is second possibility that is that I got the boost::fusion
theory totally wrong in the first place.

Thanks so much for your help,
Alfredo.

>
> Regards,
> --
> Joel de Guzmanhttp://www.boostpro.comhttp://spirit.sf.net
>
> _______________________________________________
> Boost-users mailing list
> Boost-us..._at_[hidden]http://lists.boost.org/mailman/listinfo.cgi/boost-users


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