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

Luis Ibanez luis.ibanez at kitware.com
Sat Dec 18 18:21:33 EST 2010


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/20101218/ebc8123f/attachment.htm>


More information about the Insight-developers mailing list