I have read the section on Expression templates from Vandevoorde
and Josuttis, and I have coded a lighter version of the expression
template example, and it works quite well.
In the assignment operator :
template <typename T2, typename Rep2>
Array & operator = ( Array<T2, Rep2> const & b )
for ( int idx = 0; idx < b.size ; ++idx )
expr_rep[idx] = b[idx] ;
Note that the same index "idx" is passed on to all the nested
objects.. So if I have an expression like x*y + x, then the
assignment operation would see x[i]*y[i] + x[i]. Agreed..
What if i need different indices for each of the operation, like:
x[i]*y[i+1] + x[i-1];
Lets assume that the for loop doesn't span the full data range, so as
to accommodate the i-1 and i+1 index... Is there a way to expand
b[idx] such that I can pinpoint the operands individually ?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
||9/13/2010 5:20:33 PM