Boost logo

Boost :

Subject: Re: [boost] [proto] transforms && rvalue refs
From: troy d. straszheim (troy_at_[hidden])
Date: 2009-03-30 13:17:17

Eric Niebler wrote:
> Using expression templates to eliminate unnecessary temporaries is a
> well understood idiom; it's why expression templates were invented in
> the first place. You don't need rvalue references at all.
> Could you say more about what you are trying to do and why you think
> rvalue references are needed?

Maybe I've missed something stupid or have organized things so as to
cause myself trouble. In an expression like

    // these contain pointers to memory out on the GPU
    array<float> A, B(10,10), C(10,10);

    A = exp(B) * C;

When it is time to evaluate the expression, the grammar fires the
transform for exp(B) first. It creates a temporary T with the same
dimensions as B and and a function is called to compute the result into
T. Now 'T * C' happens. In this case there is an available temporary,
'T', so the result can go right in to T. T is returned and moved in to
A. Done... at least, that's the idea.

So how should these transforms know whether their arguments are
overwritable or not? I didn't see how to get the 'slicing through the
expression' approach, as in the calc examples, with contexts and
overloaded operator[], to work here: each step of the calculation has
to get done all at once, via a function call. But maybe it is time to
go back and look again.


Boost list run by bdawes at, gregod at, cpdaniel at, john at