Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2007-10-05 07:59:28


Miles Bader wrote:
> "John Femiani" <JOHN.FEMIANI_at_[hidden]> writes:
>> 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.
>>
>> template <int Index> float get(MyPoint & p) {return p[Index];}
>> template <> float get<0>(MyPoint & p) {return p.x;}
>
> How does this work with non-constant indices? That's a significant reason
> why array-style access is useful ...

And is also a significant reason why it is so limiting. It's a
trade off -- a design choice akin to requiring all STL
sequences and containers be indexable by a runtime int. If
you want to make full use of concepts, go all the way!
You can make several levels of concepts with increasing levels
of restrictions. Somewhere near the bottom of the concept
hierarchy, you can definitely add an IndexablePoint concept,
say. For many a generic algorithm that works on points however,
I'd say that that severe requirement is not needed -- just as
much as most STL algorithms do not require RandomAccess.

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