[Insight-developers] Best method for a do-nothing return-value function
M Stauffer (V)
mstauff at verizon.net
Wed Dec 22 13:20:40 EST 2010
Hi Luis,
After looking into this more, it seems that to be able to inline a functor's function operator, I would have to template a containing class over the functor class.
Otherwise, if I were to not template and simply require the user to assign a derived functor to a containing class' member variable of type MyFunctorBaseClass, then it seems the compiler wouldn't know ahead of time the particular functor implementation that's being used, and likely couldn't inline. This then seems like the same issue with inlining a virtual method in a regular class.
Does this sound right?
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/20101222/d1b56c78/attachment.htm>
More information about the Insight-developers
mailing list