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

M Stauffer (V) mstauff at verizon.net
Fri Dec 17 22:11:38 EST 2010


Does this return 0? If so that won't work. We need to return the same
value as the input, so that nothing's changed, and there's no extra
overhead when the base class is used by default. 

>-----Original Message-----
>From: gang song [mailto:songgang97 at gmail.com] 
>Sent: Friday, December 17, 2010 9:54 PM
>To: M Stauffer (V)
>Cc: Hans Johnson; ITK
>Subject: Re: [Insight-developers] Best method for a do-nothing 
>return-valuefunction
>
>Or you can try
>return NumericTraits<TValue>::Zero;
>if zero value looks more general to your case and this has to pass the
>NumericTraits concept checking in compiling.
>
>
>On Fri, Dec 17, 2010 at 9:03 PM, M Stauffer (V) 
><mstauff at verizon.net> wrote:
>> Yes, it should simply return the input value. This is so the 
>base class
>> can be used by default w/out it actually doing anything.
>>
>> Cheers,
>> Michael
>>
>>>-----Original Message-----
>>>From: Hans Johnson [mailto:hans-johnson at uiowa.edu]
>>>Sent: Friday, December 17, 2010 7:29 PM
>>>To: M Stauffer (V); ITK
>>>Subject: Re: [Insight-developers] Best method for a do-nothing
>>>return-valuefunction
>>>
>>>Do you ever intend to use the base class Evaluate?  If not, 
>you should
>>>probably make it an abstract member function that only defines
>>>the intended
>>>interface.
>>>
>>>TValue Evaluate( TValue value ) = 0;
>>>
>>>Hans
>>>--
>>>Hans J. Johnson, Ph.D.
>>>Hans-johnson at uiowa.edu
>>>
>>>278 GH
>>>The University of Iowa
>>>Iowa City, IA 52241
>>>(319) 353 8587
>>>
>>>
>>>> From: "M Stauffer (V)" <mstauff at verizon.net>
>>>> Date: Fri, 17 Dec 2010 18:09:34 -0500
>>>> To: ITK <insight-developers at itk.org>
>>>> Subject: [Insight-developers] Best method for a do-nothing
>>>> return-valuefunction
>>>>
>>>> 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
>>>
>>
>> _______________________________________________
>> 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
>>



More information about the Insight-developers mailing list