On 6/17/2011 7:30 AM, Joel falcou wrote:
> proto expression are fusion sequence that iterates over the node
> children. All fine and dandy.
> Now here is my use case. I have expression whose terminal are fusion
> sequence that access tot he terminal values (think terminal holding a
> std:;array for example) and I wished to have expression of the terminal
> be fusion sequence themselves so i can do stuff like :
> at_c<0>( x + y * 3 )
> where x and y are such terminals, this statement returning me the
> equivalent of :
> at_c<0>( x ) + at_c<0>( y ) * 3
> Obviously, no candy as both fusion registration conflicts with each
> others. My Fusion-fu beign quite weak, is there a way to have this AND
> still have proto expressions behave as they should in other context ?

Doable, but not easy. The problem you'll have is that all Proto
expression types have a nested fusion_tag that is a typedef for
proto::tag::proto_expr. That is how Fusion figures out how to iterate
over Proto expressions. You'll need to define your own tag, use
proto::extends (not BOOST_PROTO_EXTENDS) to define an expression
extension, and hide the fusion_tag typedef in the base with your own.
Then you'll need to implement the necessary Fusion hooks for your custom
Fusion tag type.


Eric Niebler
BoostPro Computing
proto mailing list

Reply via email to