
Thanks, that does help. The other approach I was toying with was to hold the values "in situ", i.e., make int_ contain the datum.
I don't see how. When you create your "program", the data are not yet available. They are only supplied later when you are ready to execute your "program". I must be misunderstanding what you're suggesting.
Sorry, I should have been clearer. My suggestion was to make program_variable look like this. template<typename T> struct program_variable { T value; }; And in the operator(..) function of program_expr, copy the parameters to the values like so: proto::value(proto::left(proto::left(proto::left(*this)))).value = a0; proto::value(proto::left(proto::right(proto::left(*this)))).value = a1; Then call program_eval()(*this), then copy back to a0 and a1.
They shouln't, unless your generator is doing something extra.
You are right, I spoke too soon. I am attaching the code I wrote with in situ storage, based on the code you sent. And it seems to work. I like the idea of in place storage because everything is nicely packaged up in the expression object. No need for extra maps and vectors. Also, using the other way, handling different types becomes a problem. What if I want Program(&a, b) where a is int_ and b is double_.? In place storage just has the right type already. Please do let me know if you spot some inelegance or any other problem with this approach.
I was intrigued enough by this problem to have a go at implementing my suggestion above. It seems to work (see attached). This is a rough mock-up and needs much work. In particular, see the TODO for the overloaded operator() in program_expr. But on the whole, this seems workable.
Note, you'll need to use the latest version of Proto from trunk. I had to fix two bugs to get this to work. :-(
Thanks for the code, it sure would serve as an excellent use case for Proto users. Manjunath