Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-10-22 06:58:30


On 10/21/2005 04:37 PM, Korcan Hussein wrote:
> "Larry Evans" <cppljevans_at_[hidden]> wrote in message
[snip]
>>I'm afraid I don't know what:
>>
>> type deduction of intermediate results from expression templates
>>
>>means. Could you explain more with examples?
>
>
> I'll make a quote from the boost MPL book :-)
>
[snip]
That helps a lot (BTW, it's on p. 236).
[snip]
> better alternative to type erasor (unless it's already in use or have been
> discussed about). I think it would be very useful to libraries such as uBlas
> and Spirit.
>
>
[snip]
> Boost.Any is one example where type erasing is used, basically you keep
> richful type info to the very last possible moment and then lose most of it
> in a polymophic type and use dynamic dispatching etc. So it's like your
> erasing the type, would you like a code example? ;)
No. "type erasure" is in index of the MPL book; so, I'll just consult
that.
>
>
>>>parse tree of an intermediate expression and create an exact runtime
>>>replica
>>>of the expression tree using recursive variant types (using Boost.Variant
>>>in
>>>C++). The creation of the expression tree can be completely automated.
>>
>>Why would you want a runtime replica? I suppose to solve the "type
>>deduction of intermediate results" problem mentioned above, but, as
>>I've said, I don't know what this is :(
>>
>
> I think that should make a little more sense now, if not i can explain some
> more if need be ;)

Please do. I'm guessing that the replica is encoded in the variant's
which member function. IOW, just like the expression type in:

http://www.boost.org/doc/html/variant/tutorial.html#variant.tutorial.recursive

encodes the type of expression as:

   variant.which() expression type
   ----------------------------------
   1 int
   2 binary_op<add>
   3 binary_op<sub>

your proposal would do the same for each possible value of expression
type. IOW, instead of dynamic dispatching as done by type erasure,
the dispatching would be done on variant.which()?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk