[Insight-users] Template question
Luis Ibanez
luis.ibanez at kitware.com
Wed Mar 5 18:10:00 EST 2008
Hi Bill
The line:
MetricType::Pointer metric = MetricType::New();
should probably be:
typename MetricType::Pointer metric = MetricType::New();
When you refer to traits of templates inside another
templated class, you need to add the "typename" keyword.
Regards,
Luis
--------------------------
Poirier, Guillaume wrote:
>
> This is probably a simple question... I am trying to do the following:
>
> template <typename PixelFormat=unsigned char, unsigned int Dimension=2 >
> class Foo : public Foo2
> {
> [...]
>
> inline void func();
> };
>
> template <typename PixelFormat, unsigned int Dimension>
> void Foo<PixelFormat, Dimension>::func()
> {
> typedef itk::Image< PixelFormat, Dimension > FixedImageType;
> typedef itk::Image< PixelFormat, Dimension > MovingImageType;
>
> typedef itk::TranslationTransform< double, Dimension > TransformType;
> typedef itk::RegularStepGradientDescentOptimizer OptimizerType;
> typedef itk::MattesMutualInformationImageToImageMetric<FixedImageType,
> MovingImageType> MetricType;
>
> typedef itk::LinearInterpolateImageFunction< MovingImageType, double >
> InterpolatorType;
> typedef itk::ImageRegistrationMethod< FixedImageType, MovingImageType
> > RegistrationType;
>
> MetricType::Pointer metric = MetricType::New();
>
> [...]
> }
>
> g++ complains of error: expected `;' before metric. If I replace
> PixelFormat by float and Dimension by 2
> then it compiles... Sorry, I am not extremely familiar with templates
> and not sure what I am doing wrong :(
>
>
> -bill
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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