Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2006-09-15 19:38:47


--- Benoit wrote:
> Hello everyone,

Howdy!

> I have been using properties quite extensively in
> my work. And these last days I have needed to
> combine properties numerous times.
>
> By that, I mean that I have n properties p1, p2, ...
> pn and what I use is
> get( p1, get( p2, get( ..., get( pn, object )
> ... ) ) )
> I would very much want to make a composite property
> p to be used like this :
> get( p, object )
> (most of the time, n=2, but why stop there ? :-) )
>
> I have to tried to find such functionality but in
> vain so far... Does it not exist? Are there
> obstacles that i have not foreseen? I am
> thinking of something like the following:
>
> template<class Prop1, class Prop2>
> struct composite_property
> {
> composite_property(Prop1 p1_, Prop2 p2_)
> : p1( p1_ ), p2( p2_ )
> {
> }
>
> Prop1 p1;
> Prop2 p2;
> };
>
> template<class Prop1, class Prop2>
> typename property_traits<Prop1>::reference
> get(composite_property<Prop1, Prop2> comp,
> typename property_traits<Prop2>::reference
x)
> {
> return get( comp.p1, get( comp.p2, x ) );
> }
>
> How do you all feel about this? I believe it would
> be very useful!

I believe that the Fusion library provides a map that
possesses the functionality you need. You can wait
until Boost version 1.34 is released, or you can grab
a CVS snapshot in order to play with it right away.

                              HTH,
                              Cromwell D. Enage

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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