|
Boost : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-03-07 14:43:58
Pavel Chikulaev wrote:
> "Jonathan Turkanis" <technews_at_[hidden]> wrote in message
> news:d0i7jt$60a$1_at_sea.gmane.org...
>> Now that I look at your sample, I wonder whether it is possible to
>> support operators which take instances of different types. This
>> would be essential for an expression templates library.
> Example:
<snip example>
Okay, good.
> I'm predicting you're next question - Is templates supported? Yes.
> Example:
> template<typename T>
> class Matrix
> {
> static lazy::type<Matrix> Matrix_;
>
> template<typename U>
> struct Matrix__ : lazy::type<Matrix<U> > {};
> public:
>
> template<typename U>
> LAZY_OP(Matrix_ + Matrix__<U>()); //A bit uglier, isn't it?
> };
What about templates with more than one parameter:
template<typename U, typename V>
LAZY_OP(Matrix_ + Matrix__<U, V>()); // unprotected comma
>> Have you considered the approach taken by Boost.Operators?
> Not yet.
> I still don't know whether to make += lazy operator or
> code += operator as usual.
All operators should be lazy, for maximum generality.
>> Also, I believe Fusion (the sucessor to Tuple) would be a valuable
>> tool.
> Is it (same as)(old version of) Tuple?
No. (What would be the point, then?) It provides extensible tuple-like
sequences, together with a collectin of algorithms and adapters, similar to MPL.
I think it's not documented, but last time I looked at it, the design was close
enough to MPL that if you knew MPL and Tuple it would be easy to start using.
The reason I though Fusion would be relevant is that in an expression template
library, the information about a complex expression that you need to maintain in
order for it to be evaluated once it is complete is:
1. A list of all the concrete objects which particpate in the expression
2. The structure of the expression.
Fusion may provide the infrastructure for this. In the iostreams library, I used
something like a homemade tuple; but for a more ambitious implementation of
expression templates I would want to use existing tools as much as possible.
Jonathan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk