[pooma-dev] UserFunction question

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Tue Sep 3 08:39:00 UTC 2002


On 2 Sep 2002, Renato Fernandes Cantão wrote:

> Hello Guys!
>
> I've been dealing with UserFunction, but I have a question: suppose I'm
> using a UserFunction to manipulate Array's of big elements, like that:
>
>       inline InnerType_t& operator( const InnerType_t& t ) const
>       {
>          p = t * t;   // stupid example...
>
>          return p;
>       }
>
>    private:
>       InnerType_t p;   // initialized in some manner in the constructor
>
>    UserFunction< Operation > F;

As you just default construct the user function, the InnerType_t is also
default constructed. So in principle the compiler should be able to do
return value optimization if you write

inline InnerType& operator(const InnerType& t) const
{
   return t*t;
}

But of course a operator(lhs, rhs) type UserFunction could be implemented,
if you can prove the compiler does not do return value optimization
properly for expression templates.

Richard.

--
Richard Guenther <richard.guenther at uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/




More information about the pooma-dev mailing list