[Boost.Proto] implementing function call operators in expression trees
I am trying to implement function call operators with Boost.Proto but cannot seem to figure out either how to set the expression trees up or how to evaluate them properly. The code below is simplified from the “checked calculator” example in the Proto documentation to focus on implementing a single identity function resulting from the Proto expression ‘identity(_1)’. The program prints the following
function(
terminal(9identity_)
, terminal(0)
)
result=0 [ expect 3 ]
so I think the expression tree is correct. (I am, however, uncertain why the placeholder is reported as ‘terminal(0)’.)
When the expression tree is evaluated with IdentityGrammar transform, the result is 0 not 3 as I would have expected if the placeholder value was used.
The Proto documentation seems very thorough (at least after study), but is thin on the use of functions like this and is not helping me figure out the solution. I welcome any help that will point out the flaw(s) in this code for either setting up the expression tree or getting it evaluated correctly by calling the identity function with the correct argument.
Thanks for your help.
Cheers,
Brook
#include
{};
template<typename Expr>
struct identity_expr;
struct identity_domain
: proto::domain
participants (1)
-
Brook Milligan