[ITK-dev] itk::DynamicCast<>() and itk::ConstCast<>() working with itk::SmartPointer<>

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Feb 27 09:54:03 EST 2015


Hello Stephane,

Thank you for considering contributing this upstream.

So your suggestions to change:

dynamic_cast<SomeOtherType*>(smartPointer.GetPointer())

to

itk::DynamicCast<SomeOtherType>(smartPointer)


While this may save a few characters on a line I am not sure it is worth the trouble. 



Also the declaration of ConstCast could use some additional consideration. You may only want one template parameter, there T1 and T2 are always the same. The const_cast operator does not do any other type conversion other than changing the const qualifier or volatile, so this template parameter change would help to enforce that.
 

Brad


On Feb 27, 2015, at 4:54 AM, Stéphane ALBERT <otb.salbert at gmail.com> wrote:

> Hello,
> 
> I wrote dynamic_cast<>() and const_cast<>() like operators to work with itk::SmartPointer<> for the OTB/Monteverdi2 project.
> 
> I think they could be contributed to ITK (for example in the itkSmartPointer.h header file).
> 
> You will find enclosed a itkCasts.h file with the source code of these operators. This file is an extract from: http://hg.orfeo-toolbox.org/Monteverdi2/file/df0184bc51a3/Code/Common/Core/mvdTypes.h#l63 .
> 
> Best regards,
> 
> Stéphane
> 
> -- 
> http://orfeo-toolbox.org
> 
> Stéphane ALBERT
> Ingénieur d'études et développement
> Business Unit E-SPACE & Geo Information, Département APPLICATIONS
> 
> CS Systèmes d'Information
> Parc de la Grande Plaine - 5, Rue Brindejonc des Moulinais - BP 15872
> 31506 Toulouse Cedex 05 - France
> 
> <itkCasts.h>_______________________________________________
> 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.php
> 
> 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://public.kitware.com/mailman/listinfo/insight-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20150227/de754067/attachment.html>


More information about the Insight-developers mailing list