目前我正在做:
if(dimension == 2) { typedef itk::Image<short,2> ImageType; typedef itk::Image<unsigned int,2> IntegralImageType; m_pApp->train<2,ImageType,IntegralImageType>(); } else { typedef itk::Image<short,3> ImageType; typedef itk::Image<unsigned int,3> IntegralImageType; m_pApp->train<3,IntegralImageType>(); }
但我想这样做:
if (dimension == 2) DIMENSION = 2; else DIMENSION = 3; typedef itk::Image<short,DIMENSION> ImageType; typedef itk::Image<unsigned int,DIMENSION> IntegralImageType; m_pApp->train<DIMENSION,IntegralImageType>();
我无法做到这一点,因为c需要const变量用于模板实例化.
有没有这样的方法呢?