
Boost : 
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 20050311 05:11:51
Pavel Chikulaev wrote:
> "Tobias Schwinger" <tschwinger_at_[hidden]> wrote in message
> news:d0qot3
>
>>Can you provide some background information ?
>
> Example one:
> same old class Matrix {
> Matrix(LAZY_OP((Matrix_ + Matrix_ ) * Matrix_));
> Matrix(LAZY_OP(Matrix_ * ( Matrix_ + Matrix_)));
> };
> //..
> Matrix a, b, c, d, e;
> e = (a + b) * (c + d);
> //What to choose: first or second?
> //I mean
> //First:
> //Matrix t = c + d;
> //e = (a + b) * t;
> //Second:
> //Matrix t = a + b;
> //e = t * (c + d);
> //My idea is to add unique number to each narity operator
> //(some kinda weight of operator), and choose the narity operator
> //with maximum value.
> //So I really need that max_possible_N_of_all_B_specializations<T>::value.
>
Honest answer: I belive this idea is no good.
> Example two:
> same old class Matrix {
> Matrix(LAZY_OP((Matrix_ + Matrix_) * (Matrix_ + Matrix_)));
> Matrix(LAZY_OP(Matrix_ * (Matrix_ + Matrix_ * Matrix_))));
> };
> //..
Is it necessary to specify such rules ?
Isn't it enough to tell your lib operator + and operator * are
"expression object factories" rather than imperative routines ?
It might be possible to partially allow stuff like this using
overloading [ ref. 14.5.5.2 ], but the possibility of creating ambigous
situations can't be fully eliminated.
> Matrix a, b, c, d, e, f;
> f = (a + b) * (c + d * e);
> //Again: First or Second?
Neither, it is ambigous.
Regards,
Tobias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk