|
Boost : |
From: Benoit (benoit.casoetto_at_[hidden])
Date: 2006-09-15 02:35:24
Hello everyone,
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 !
-- Benoît Casoetto
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk