Even by explicitly mentioning that the parameter in the function pointer is const, it doesn’t seem to be able to convert the function to this type:
#include <iostream>
template <typename T>
class Image{};
template <typename TPixel>
static void
FillImage(const Image<TPixel>* const image){}
//FillImage(Image<TPixel>* const image){} // Replacing the above line with this one compiles fine
int main()
{
typedef Image<float> ImageType;
ImageType* image = new ImageType;
void (*autoFunctionPointer)(const decltype(image)) = FillImage;
autoFunctionPointer(image);
}
Can anyone explain how to make it do that conversion?
The
constapplies to the pointer.So,
const decltype(image)is equivalent toImageType* constand notconst ImageType*If you change
imagetothe first version of
FillImage()works as expected.To get a
const ImageType*you can use std::remove_pointer