Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2007-10-04 21:34:19


John Femiani wrote:

> What is not lightweight about the get<0>(pt) syntax? Doesn't it compile
> away? Is the issue a dependency on another library -- because the
> get<0>(pt) syntax seems really easy to provide without bothering with
> Fusion.
>
> i.e.
> template <int Index> float get(MyPoint & p) {return p[Index];}
> OR
> template <> float get<0>(MyPoint & p) {return p.x;}

Dependency is indeed an issue. Sure you can get by with the simple
interface above. I think that's the barest minimum. Perhaps the next
step is to provide an optional mapping to fusion when explicitly
specified by the client. This would be desirable in cases where the
client directly or indirectly uses fusion anyway. The advantage
in making your structs full fledged fusion sequences will become
apparent when you go into more generic programming. The simplest
would be, say, iterating to all the (possibly heterogeneous)
dimensions and applying some generic algorithms on them.

All that being said, while taken as a whole, fusion might indeed
be big, the core code that deals with iterators and adopting
is rather lightweight. You only pay for what you use. The
iterators and adapters are only two cents a piece ;-)

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk