freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pooma-dev] UserFunction question


From: Richard Guenther
Subject: Re: [pooma-dev] UserFunction question
Date: Tue, 3 Sep 2002 10:39:00 +0200 (CEST)

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 <address@hidden>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]