
7 Mar
2011
7 Mar
'11
7:52 a.m.
How would the expression's code know anything about x, or have access to its allocated memory? If the template is operator+, you'd have to pass x to it somehow. If it's not, operator+ would have to allocate some memory for a temporary, wouldn't it?
x just have a operator= taking a interge_expression<X> type whcich contains the whole a+b abstract syntax tree. From there, there is countless techniques to iterate over the AST, transform it or evaluate it as code.