[Insight-developers] assert and explicit instantiations

Julien Jomier julien.jomier at kitware.com
Mon Jun 15 11:55:23 EDT 2009


Hi Gaetan,

Thanks for looking into this. I ported the code from another group (in 
Germany) a couple years ago and left the assert functions. I think we 
should follow the same rule that the Image iterators: no checks when 
incrementing/decrementing and probably no check when setting the function.

Julien

Gaëtan Lehmann wrote:
> 
> Le 14 juin 09 à 18:43, Luis Ibanez a écrit :
> 
>>
>>
>> Hi Gaetan,
>>
> 
> Hi Luis,
> 
>> You should probably use the new Macro:
>>
>>           itkAssertOrThrowMacro
>>
>>
>> That is defined in
>>
>>      Insight/Code/Common/itkMacro.h
>>
>>
>> It will use Asserts when compiled in Debug mode,
>> and it will throw Exceptions when compiled in
>> Release mode.
> 
> Well, we should carefully use that macro, because exceptions can have 
> serious impact on performance.
> In that case, the assert() is in operator++() and Set() methods of an 
> iterator.
> 
>   
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkTreeIteratorBase.h?root=Insight&r1=1.12&r2=1.13&sortby=date 
> 
>   
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkTreeIteratorBase.txx?root=Insight&r1=1.14&r2=1.15&sortby=date 
> 
> 
> This is the kind of case where I wouldn't replace an assert() by 
> itkAssertOrThrowMacro(), or at least without carefully measuring the 
> execution times.
> 
> Regards,
> 
> Gaëtan
> 
>>
>>
>>
>>  Luis
>>
>>
>> -----------------------
>> Gaëtan Lehmann wrote:
>>> Hi Julien,
>>> I have commented an assert() in
>>>  Code/Common/itkTreeIteratorBase.h
>>>  Code/Common/itkTreeIteratorBase.h
>>> to fix build with explicit instantiation.
>>> The compiler was giving that error:
>>> /export/home/glehmann/src/Insight/Code/Common/itkTreeIteratorBase.h: 
>>> 182: erreur: ‘assert’ was not declared in this scope
>>> Is it the expected behavior?
>>> Thans,
>>> Gaëtan
>>> ------------------------------------------------------------------------
>>> _______________________________________________
>>> Powered by www.kitware.com
>>> Visit other Kitware open-source projects at 
>>> http://www.kitware.com/opensource/opensource.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