An evaluation context adaptor that makes authoring a context a simple matter of writing function overloads, rather then writing template specializations. More...
#include <proto_fwd.hpp>
Classes | |
struct | eval |
A BinaryFunction that accepts an Expr and a Context , and either fans out the expression and passes it to the context, or else hands off the expression to DefaultCtx . More... | |
An evaluation context adaptor that makes authoring a context a simple matter of writing function overloads, rather then writing template specializations.
callable_context<>
is a base class that implements the context protocol by passing fanned-out expression nodes to the derived context, making it easy to customize the handling of expression types by writing function overloads. Only those expression types needing special handling require explicit handling. All others are dispatched to a user-specified default context, DefaultCtx
.
callable_context<>
is defined simply as:
The Boolean metafunction is_expr_handled_<>
uses metaprogramming tricks to determine whether Context
has an overloaded function call operator that accepts the fanned-out constituents of an expression of type Expr
. If so, the handling of the expression is dispatched to callable_eval<>
. If not, it is dispatched to the user-specified DefaultCtx
.
Below is an example of how to use callable_context<>
:
With increment_ints
, we can do the following: