D
Dominic Chandar
Hi,
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*y + x. Agreed..
What if i need different indices for each of the operation, like:
x*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 ?
-Dominic
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*y + x. Agreed..
What if i need different indices for each of the operation, like:
x*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 ?
-Dominic