jeudi 30 avril 2020

Not using constexpr in c++ template arguments

I am working with a variable of type itk::Image<OutputPixelType, Dimension>, where "itk" comes from the image processing library ITK.

The following code compiles:

constexpr unsigned int Dimension = 3;
using PixelType = float; 
using MyImageType = itk::Image<PixelType, Dimension>;

But now I need to define "Dimension" as something computed from a function.

unsigned int Dimension = get_dimension(...);

My compiler gives an error:

error: non-type template argument is not a constant expression
  using MyImageType = itk::Image<PixelType, Dimension>;
                                            ^~~~~~~~~

How could I work around this issue? I hope to use "Dimension" as something computed from a function.

Aucun commentaire:

Enregistrer un commentaire