On Jan 14, 2011, at 12:29 PM, Nate Knight wrote:

> I've pasted some code below where I am trying to transform expressions of the 
> form
> 
> (a op b op c)[i] 
> 
> to 
> 
> (a[i] op b[i] op c[i])
> 
> I managed to get this to work for the simple case
> 
> (a+b)[i]
> 
> but I'm curious about how to generalize this to include other operators 
> (without explicitly handling them all).  Also, as written the transform 
> doesn't recurse properly, and I'm having some trouble seeing how to correct 
> this.

I figured out the recursion problem.  This should have been obvious to me.  
Generalizing the transformation to other subexpressions still eludes me due to 
an issue illustrated below.

struct vec 
    : or_<
          when<
              subscript< binary_expr<_,vec,vec>, terminal<_> >
            , functional::make_expr< ??? >(
                  vec(
                    functional::make_expr<tag::subscript>(
                      _left(_left), _right
                    )   
                  ),  
                  vec(
                    functional::make_expr<tag::subscript>(
                      _right(_left), _right
                    )   
                  )   
              )   
          >   
        , plus< vec, vec >
        , minus< vec, vec >
        , terminal< _ > 
      >   
{};

How do I (or can I at all) get the tag of the matched binary expression to pass 
back to make_expr?  Perhaps I'm still going about this the wrong way?

Thanks
Nate

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto

Reply via email to