[Insight-users] Handling multiple number types

Hendrik Belitz hbelitz at darkon.info
Tue Feb 13 03:50:57 EST 2007


>Greetings,
>
>My code needs to be able to apply a given filter to any number type  
>(short, long float etc.)  Is there a more elegant solution other than  
>instantiating each supported case?  This could get ugly pretty  
>quickly considering 8 number types in each supported dimensions.
>
>TIA,
>
>AG
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users

You could at least reduce the programming effort by introducing a type list (see Alexandrescus Modern C++ Design for details) for all types you want to support. This would allow you to write templated methods calling the appropiate ITK pipeline for generic types, with the specific type being determined at runtime and the specific method being automatically called. This would give your source code a much cleaner look, but will result in longer compile times. Additionally, creating and using type lists is a real pain if you never did this before. And in your specific case, you'll need to orthogonal type lists, one for number type and one for dimension.

Regards
 Hendrik


More information about the Insight-users mailing list