[Insight-developers] Best method for a do-nothing return-value function

M Stauffer (V) mstauff at verizon.net
Tue Dec 21 22:13:32 EST 2010


Thanks Luis, I'll look to do it as a functor.
 
Cheers,
Michael 


  _____  

From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
Sent: Saturday, December 18, 2010 6:22 PM
To: M Stauffer (V)
Cc: ITK-dev-list
Subject: Re: [Insight-developers] Best method for a do-nothing return-value function


Hi Michael,

This call looks reasonable, note however that 
if you declare the function to be "virtual" as you
probably need to do in this case in order to 
achieve polymorphism, then the call to this function
will not be inlined.

The typical option here is to use Functors, if you
want to get both the flexibility of polymorphism,
and the efficiency of inlining.


������ Luis



On Fri, Dec 17, 2010 at 6:09 PM, M Stauffer (V) <mstauff at verizon.net> wrote:


Hi,

I'm not sure how to phrase the subject. I'm creating a function base
class whose "Evaluate", i.e. do-its-thing, method needs to simply return
the input value. Derived classes will modify the value in some way, not
surprisingly.

Is there a more efficient way to implement this than what I have below?
I figure most compilers will actually make this inline, but maybe not
all?

< typename TValue >
class FunctionBase {

...
��inline TValue Evaluate( TValue value ) { return value; }
...

};

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101221/7604d3c0/attachment.htm>


More information about the Insight-developers mailing list