
proto::make_expr tries to enforce uniformity in the trees it returns. In particular, it wants all the child nodes to be in the same domain as the parent node it returns. When the domains don't match (as they don't in this case because int32_ is in the default_domain), it passes the child through the domain's generator.
I follow you up to here.
The result gets stored by value instead of by reference as you're requesting.
I lost you here. In my case, I pass program_() and boost::ref(a0) as children to make_expr. My generator would match otherwise(_) rule (I don't have it in the program I sent, but suppose I add it to program_generator). So the result is the expression unmodified, no? What gets stored by value, where, like you say?
The fix is quite simple. Define int32_ as follows:
typedef proto::literal int32_;
That puts it in the program_domain.
I gave this a try, and it works fine.
Also, you should note that your generator is broken. It only handles the function
case. Passing any other expression to it violates its preconditions. You need an otherwise<_> in there.
(BTW, I just added a default constructor to literal to make your code compile.)
Thanks. Manjunath