Incorrect function template being selected?
===

(Please excuse the complex example - as you'll see below I could not reproduce the problem with a simple example).

I have a function:

    template <typename TPixel>
    class PoissonEditing
    {
        template <typename TComponent, int NumberOfComponents>
        static void FillImage(const itk::Image<itk::CovariantVector<TComponent, NumberOfComponents>, 2>* const image,
                              const Mask* const mask,
                              const GuidanceFieldType* const guidanceField,
                              itk::Image<itk::CovariantVector<TComponent, NumberOfComponents>, 2>* const output);
    }

It is being called with:

      typedef float ComponentType;
    
      typedef itk::Image<itk::CovariantVector<ComponentType, 3>, 2> ImageType;
    
      ImageType::Pointer image = ImageType::New();
      ImageType::Pointer output = ImageType::New();
    
      Mask::Pointer mask = Mask::New();
    
      typedef PoissonEditing<ComponentType> PoissonEditingType;
    
      PoissonEditingType::GuidanceFieldType::Pointer guidanceField = PoissonEditingType::GuidanceFieldType::New();
    
      PoissonEditingType::FillImage(image.GetPointer(), mask,
                                    guidanceField.GetPointer(), output.GetPointer());

but for some reason it is instead matching to:

    template <typename TPixel>
    template <typename TScalarPixel>
    void PoissonEditing<TPixel>::FillImage(const itk::Image<TScalarPixel, 2>* const image, const Mask* const mask,
                                           const GuidanceFieldType* const guidanceField, itk::Image<TScalarPixel, 2>* const output)
    {
      FillScalarImage(image, mask, guidanceField, output);
    }


I tried to reproduce, but it works correctly in the simple demo:

    #include <iostream>
    
    template <typename TPixel>
    struct Image
    {
    };
    
    template <typename TComponent, int NumberOfComponents>
    struct Vector
    {
    };
    
    template <typename T>
    struct TestStruct
    {
      template <typename TImage>
      static void Function(TImage a)
      {
        std::cout << "Image" << std::endl;
      }
    
      template <typename TComponent, int NumberOfComponents>
      static void Function(Image<Vector<TComponent, NumberOfComponents> > a)
      {
        std::cout << "Image<Vector>" << std::endl;
      }
    };
    
    int main()
    {
      Image<int> image;
      TestStruct<float>::Function(image);
    
      Image<Vector<int, 2> > vectorimage;
      TestStruct<float>::Function(vectorimage);
    
      return 0;
    }

outputs:

    Image
    Image<Vector>

Shouldn't it match to the one I was expecting because it is "more specialized" (specialized in the sense of the English word, nothing to do with "template specialization)?

Anyone have any clues of why these might not be matching how I would expect?

