简体   繁体   中英

How can I add parent references to Boost.Proto expressions?

I want to generate expression trees that have "reverse" references from child to parent. Is there a way to customize the Proto generator or domain so that the expression wrapper class (using proto::extends<> ) contains a reference to the parent expression?

The goal behind this is to create expression trees that cache evaluated results, so that they can be re-evaluated efficiently. My strategy is to update terminal values, and then walk up the tree marking parent nodes as "dirty" so that they will be re-evaluated when the root expression is evaluated.

The technique you describe can't work. Expressions are built bottom-up. For the expression a + (b * c) , the parent node ( + ) doesn't exist at the time the child node ( b * c ) is constructed. The child can't store a pointer to an object that doesn't exist yet.

You would have to post-process expressions to set the parent pointers using a transform or context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM