[Insight-users] question about casting

Luis Ibanez luis.ibanez at kitware.com
Mon Aug 14 08:56:03 EDT 2006



Hi Christoph,


Thanks for pointing this out.


                   This is a bug.


As you indicate, having a run-time check is not going to prevent
a compilation-time problem.

We should add a MetaProgramming boolean check here in order to make
those lines conditional. That is, we should replace the "if" statement
with a Template expression that is equivalent to a boolean check.



Could you please report this as a bug in the bug tracker:

      http://public.kitware.com/Bug/index.php


Please let us know if you find any problem logging in the bug
tracker.



    Thanks



       Luis



----------------------
Christoph Palm wrote:
> Dear all,
> 
> I have a question about the casting in the itkCannyLevelsetFunction.txx.
> There, we can find the following code:
> 
> 
>   // Only cast if we need to
>   if ( typeid(TImageType) == typeid(TFeatureImageType))
>     {
>     m_Canny->SetInput(tempFeature);
>     }
>   else
>     {
>     m_Caster->SetInput(tempFeature);
>     m_Canny->SetInput(m_Caster->GetOutput());
>     }
> 
> My problem: if I try to use and compile this with
> TImageType != TFeatureImageType, the compiler
> stops with an error message like
> "casting not possible" in m_Canny->SetInput(tempFeature);
> Obviously, at run-time there is no problem because of the
> if-statement, but at compile-time, the compiler does not
> know, that this casting problem never will occure.
> 
> Did I get someting wrong here?
> 
> Possible solution:
> Omit the if-statement and use the caster in every case.
> If a cast is not need, the casting is just bad for the
> run-time but not wrong at all.
> 
> Any suggestions?
> 
> Best regards
> 
> Christoph 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 




More information about the Insight-users mailing list