Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Expression Evaluation: Imparting Behaviors with a Context

Evaluating an Expression with proto::eval()
Defining an Evaluation Context
Proto's Built-In Contexts
default_context
null_context
callable_context<>

Once you have constructed a Proto expression tree, either by using Proto's operator overloads or with proto::make_expr() and friends, you probably want to actually do something with it. The simplest option is to use proto::eval(), a generic expression evaluator. To use proto::eval(), you'll need to define a context that tells proto::eval() how each node should be evaluated. This section goes through the nuts and bolts of using proto::eval(), defining evaluation contexts, and using the contexts that Proto provides.

[Note] Note

proto::eval() is a less powerful but easier-to-use evaluation technique than Proto transforms, which are covered later. Although very powerful, transforms have a steep learning curve and can be more difficult to debug. proto::eval() is a rather weak tree traversal algorithm. Dan Marsden has been working on a more general and powerful tree traversal library. When it is ready, I anticipate that it will eliminate the need for proto::eval().


PrevUpHomeNext