MantisBT - ITK
View Issue Details
0003610ITKpublic2006-08-15 01:512010-10-26 15:07
Christoph Palm 
kentwilliams 
highmajoralways
closedopen 
 
 
backlog
0003610: casting problem (run-time vs. compile-time)
in itkCannyLevelsetFunction.txx:

  // 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());
    }

Cannot be compiled with
TImageType != TFeatureImageType,
because 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.

Luis Ibanez proposed the following solution:

"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."
Gerrit topic http://review.source.kitware.com/#change,240 [^] implements solution.
No tags attached.
Issue History
2010-10-21 12:17Hans JohnsonAssigned ToLydia Ng => Luis Ibanez
2010-10-21 12:17Hans JohnsonNote Added: 0022591
2010-10-21 12:18Hans JohnsonAssigned ToLuis Ibanez => kentwilliams
2010-10-21 12:19Hans JohnsonNote Added: 0022592
2010-10-26 14:24kentwilliamsSprint Status => backlog
2010-10-26 14:24kentwilliamsDescription Updated
2010-10-26 14:24kentwilliamsAdditional Information Updated
2010-10-26 15:07kentwilliamsStatusassigned => closed

Notes
(0022591)
Hans Johnson   
2010-10-21 12:17   
This is still an issue.
(0022592)
Hans Johnson   
2010-10-21 12:19   
This can be solved at compile time by having a templated class with a boolean argument. See concept checking classes for a model to follow.